Sort by number sorts incorrectly


Notice in the screenshot, that sorting by a number or text field with a number is doing lexicographic sorting, which means basically the language treats the variables as strings and compares character by character ( "200" is greater than "19999" because '2' is greater than '1' ).

This should probably be fixed, as documentation (a cockpit use case) is often numbered in various ways:

  • 1
  • 1.1
  • 1.1.1
  • 1-1-1


Are there any plans to fix this? Or offer numerical sorting capabilities?

I don’t know about the work in progress but given that there was no reply to your request yet I’d assume there will most likely be no timely “fix” for this matter.

A “fix” for your situation could be to come up with an additional field that is auto-updated on create/edit and keeps a “sortable” string representation of the version or the numerical value in question.

For a “normal” integer value this is quite simple by dividing it by “a large number”

1  --> 0.0000000001
2  --> 0.0000000002
10 --> 0.0000000010

For a more complex value like a “version code” you might follow a similar approach by dividing each individual element and then concat the results like e.g.

1.1    --> 0.001-0.001
2.1    --> 0.002-0.001
10.1   --> 0.010-0.001
10.5.3 --> 0.010-0.005-0.003

Then you designate this new field to be

  • not shown in the table as a key (because it would only be confusing)
  • but being the “sortby” field