Numerical sort

General discussion related to "Everything".
Post Reply
w64bit
Posts: 253
Joined: Wed Jan 09, 2013 9:06 am

Numerical sort

Post by w64bit »

If I display the files by name, the sort is literal:
file1
file11
file2

Is there any setting to use in order to display the files by name with numerical sort (like in File Explorer)?
file1
file2
file11

Thank you.
NotNull
Posts: 5458
Joined: Wed May 24, 2017 9:22 pm

Re: Numerical sort

Post by NotNull »

Some time ago I was looking for this, too, but couldn't find it.


After some thinking I concluded for myself that I didn't want it anyway, for a couple of reasons:

- "Computer-sort" is fast. "Human-sort" comes at an extra 'price' (especially when you have to sort hundreds of thousands or even millions of filenames, like in Everything). My guess is that it will have some serious impact on the speed of Everything.
- What about decimal numbers? In decimal numbers, 2.5 > 2.11 , but when you talk about (software) versions, 2.11 > 2.5. How can a sorting algorithm distinguish between those?
- Which get even more confusing if you consider that in (for example) my country the "," is the decimal separator and "." is the thousands separator.
- And what to do with hex numbers?

Anyway, I gave up and 'surrendered' to computer-sort ...

BTW: Microsoft calls this 'numerical sort' and there is a Group Policy to change it's behaviour in Explorer (the file manager)
EDIT: WHich means that there might be a Windows API that can be called to force this numerical sorting
therube
Posts: 4955
Joined: Thu Sep 03, 2009 6:48 pm

Re: Numerical sort

Post by therube »

A sorting method uses some algorithm, so based on the method used it is always "right".

So an ascii sort gives one set of results.
And a "natural" (or numeric) sort gives another set of results.

Both are "right".

A users perception or a software writers intention are what leads to questions ;-).

Is software 2.11 > 2.5 ?
Did the author actually mean 2._0_5 or 2._5_.0?
If the latter, then 2.50 > 2.11.

Hex is a really good question, which I posed here, https://forum.altap.cz/viewtopic.php?f=4&t=35485 (& which I did not get an adequate answer, & which I'll revisit at some point.) [DIR, Everything, & unix sorts using various options all returned the same results. But Salamander's "Numeric" sort returned, to what seemed to me, to be illogical results - but, it must fit the algorithm they've used, so in that respect, is correct ;-)]


Anyhow, "natural sort", in Everything was long ago put on a todo list.


Note the "numbers" that start with "00".
And then also the "0A05" entry toward the top of the list.

https://s25.postimg.org/q7ful6z4t/Salam ... umbers.png
void
Developer
Posts: 16683
Joined: Fri Oct 16, 2009 11:31 pm

Re: Numerical sort

Post by void »

There will be a performance hit with natural sorting.

Having the option to enable or disable natural sorting is difficult, as Everything likes to know how the database is sorted ahead of time, having multiple paths for different sorting complicates things..
Also changing this option would force a complete rebuild of the database.

Sorting is generally only done once when indexing, so this feature will most likely be implemented for Everything 1.5, with no option to disable it.

It would be a simple 0-9 only natural sort. Decimal points would work fine as the dot (.) will break the numbers up, eg 2.11 > 2.5: 2==2, .==. and 11>5

Unfortunately, commas (,) will also break the natural sort, eg: 5,000 < 20 (5 < 20)

Hex letters would not be supported, as there is no way to know if they are really hex letters or non-hex letters.
Post Reply