manyfold icon indicating copy to clipboard operation
manyfold copied to clipboard

Sort numbers as ints rather than strings

Open Aevaris opened this issue 1 year ago • 2 comments

Describe the bug Currently, it looks like model names are sorted solely as strings. It'd be nice if numbers were sorted as ints. Right now 14Kakuna sorts after 149dragonite (or if there was a way to mass add leading 0s).

To Reproduce Steps to reproduce the behavior:

  1. Make a model named 14Kakuna and 149dragonite.
  2. See that Kakuna sorts before dragonite.

Expected behavior 14Kakuna sorts before 149dragonite.

Aevaris avatar Feb 20 '25 02:02 Aevaris

Changing to feature rather than bug, but yes, I agree, that's a good shout. At the moment all sorting is done by the database, I wonder if there's a way we can make it numeral-aware...

Floppy avatar Feb 20 '25 11:02 Floppy

https://dba.stackexchange.com/questions/285222/how-to-treat-numbers-within-strings-as-numbers-when-sorting-a3-sorts-before

https://dbfiddle.uk/cptUkufH

https://www.postgresql.org/docs/12/collation.html#id-1.6.10.4.5.7.5

ccatlett1984 avatar Mar 04 '25 00:03 ccatlett1984