Sorting numerically, not alphabetically
Hi!
I use DokuWiki for stock-taking. I label items in my company with stickers. Each sticker contains a number.
I add items to my wiki with Data and Bureaucracy. Each item has an "id" field that contains the number from sticker. I want the table of items to be sorted by that field by default.
The problem is that datatable sorts the column alphabetically:
1, 10, 11, 2, 3, 4, 5 ,6, 7, 8, 9
I want the numbers to be sorted numerically:
1, 2, 3, 4, 5 ,6, 7, 8, 9, 10, 11
You know best how to implement that. Maybe with a new data type, e. g. id_int, maybe with a new sort symbol, e. g. sort : $int, maybe somehow else.
Maybe this is a helpful tric: http://stackoverflow.com/a/11808592 On short term i'm too busy, but later...
https://www.sqlite.org/datatype3.html#comparisons
I think the additional syntax for sort should be relatively easy to add, assuming the casting won't make any problems for SQLite: https://github.com/splitbrain/dokuwiki-plugin-data/blob/master/syntax/table.php#L160-L167
Also the sorting has its problems with Umlauts e.g ä, ö, ü
Accents sorting is a collation problem which AFAIK is solved by offloading sorting to PHP via createCollation – maybe there is a native support for Unicode collation in SQLite, but I didn't find anything; anyway, I think this should be reported separately, @endoanaconda.
…unless collation could be the way to treat this issue too, by collating numeric strings and sorting them naturally. This would not need a syntax change and would work ‘automagically,’ though I am not sure about performance impact.
Please report a separated issue. This issue is only about sorting numerically.
The offloading of groupconcatenate to a php function results already in performance complains. If possible, I will avoid collation by php..
We use the PDO sqlite, so far i see, there the createCollation() is not available.
What about numerical sorting?
How soon will it be implemented in plugin?