dokuwiki-plugin-data icon indicating copy to clipboard operation
dokuwiki-plugin-data copied to clipboard

Sorting numerically, not alphabetically

Open lolmaus opened this issue 12 years ago • 8 comments

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.

lolmaus avatar Apr 12 '13 12:04 lolmaus

Maybe this is a helpful tric: http://stackoverflow.com/a/11808592 On short term i'm too busy, but later...

Klap-in avatar Apr 12 '13 13:04 Klap-in

https://www.sqlite.org/datatype3.html#comparisons

Klap-in avatar Mar 21 '14 11:03 Klap-in

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

jnv avatar Apr 27 '14 23:04 jnv

Also the sorting has its problems with Umlauts e.g ä, ö, ü

endoanaconda avatar Sep 09 '14 07:09 endoanaconda

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.

jnv avatar Sep 09 '14 08:09 jnv

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..

Klap-in avatar Sep 09 '14 08:09 Klap-in

We use the PDO sqlite, so far i see, there the createCollation() is not available.

Klap-in avatar Sep 09 '14 08:09 Klap-in

What about numerical sorting?

How soon will it be implemented in plugin?

Xeenych avatar Jul 22 '16 09:07 Xeenych