'How do I sort a text column with numbers (title 1, title 2, ...)

I want to sort a text column in natural sort order. Text column means, that the column was created as TEXT in SQLite. (Create Table...`id` TEXT).

title 1
title 2
..
title 10

I use this query:

'select id from t order by Cast(id as Integer)'

This returns title 1, title 10, title 2, ...

Here you can find a small SQLFiddle Link.



Solution 1:[1]

Thanks to Alejandro.

Solved it in Java code using a custom Comparator.

GGK

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 GGK stands for Ukraine