src/Component.php
public function inOrder($field, array $ids)
    {
        $sql = $field.' IN('.implode(',', $ids).') ORDER BY CASE '.$field;
        foreach (array_values($ids) as $num => $id) {
            $sql .= ' WHEN '.$id.' THEN '.$num;
        }
        $sql .= ' ELSE NULL END ASC';

        return $sql;
    }
public function inOrder($field, array $ids)
    {
        $sql = $field.' IN('.implode(',', $ids).') ORDER BY CASE '.$field;
        foreach (array_values($ids) as $num => $id) {
            $sql .= ' WHEN '.$id.' THEN '.$num;
        }
        $sql .= ' ELSE NULL END ASC';

        return $sql;
    }
Returns the ``$field . 'IN(' . implode(',', $ids) . ')'``, in the same order given.  This method is patterned after using MySQL's [FIELD()](http://dba.stackexchange.com/questions/109120/how-does-order-by-field-in-mysql-work-internally) function, which unfortunately is unavailable in SQLite.

@param string $field Database column.
@param array  $ids   Those passed to the IN() clause.

@return string An SQL string to put at the end of your query.

@example

```php
if ($ids = $db->ids('SELECT id FROM employees ORDER BY name ASC')) {
foreach ($db->all(array(
'SELECT name, title FROM employees',
'WHERE '.$db->inOrder('id', $ids),
)) as $row) {
list($name, $title) = $row;
}
}
```