8

I am quite new to Debian 8.4. I am not sure if this is the right community on stackexchange to pose this question. Please tell me, if not.

My question: I am using the Nautilus file manager. I view a directory with some files in list view. Then I click on the bar with 'Name' on it. The order of sorting changes. My question is: How does Nautilus sort the files if I click on this button. More specifically, what is the sort order? e.g I have four files - and _ and a and b. If I have them sorted in ascending order (I call it this way, if a is before b) then _ will be before -. What is the general rule for sorting in Nautilus? And how could I find this information on my own - for example in the source code? I spent half an hour searching the web...

2
  • 2
    nautilus follows your locale collation rules (which determine the sort order). Commented May 19, 2016 at 23:38
  • 1
    @don_crissti Collation affects how it sorts the characters it chooses to sort. But the point here is that it ignores some when evaluating sort order. Commented Oct 19, 2016 at 18:35

5 Answers 5

3

A very good question.

It seems that the underlying answer lies in the Unicode sort algorithm.

I started to read through this out of interest, got as far as normalisation but then my brain exploded. I therefore conclude that all sorting is done by magic and let it go at that.

2

"_" or "-" or other symbols do not have any impact at all, only the following letters are relevant for sorting. It's really annoying but I guess sort options are too hard to code for the devs…

3
  • 1
    Are you sure about that this is generally the case? See the comment under OP's question, what's your collate setting? Also, did you find that out through trial and error or can you please cite any sources? Commented Jul 17, 2016 at 15:22
  • 1
    but I guess sort options are too hard to code for the devs… Lame attempt at a dig. Rather it's probably a deliberate decision so that things sort lexically, by the intuitively sorted alphanumerical characters only - rather than expecting general users to know/remember/not be baffled by the arcane sorting order of non-alphanumeric characters in their particular collation. While you and I might be well versed in the old trick of 'put an underscore at the front so it sorts first', the general desktop user definitely would never predict this intuitively. GNOME aims to be inclusive of those users Commented Oct 19, 2016 at 18:37
  • 2
    Learning such a thing about characters like _ isn't that hard; and the behaviour of just ignoring them is incredibly annoying. Commented Jun 19, 2020 at 20:25
1

Nautilus takes the "ls sort order" of the operating system (which is not always the same) and adds natural sorting to it.

1

Try to use this command:
update-locale LC_COLLATE=C

More Explanation here: https://askubuntu.com/a/243012/1565970

-1

Nautilus used to have these options :

View >> Arrange Items >>>
1  Manually
2  By Name
3  By Type
4  By Modification Date
5  By Emblems

Suggest "By Name", then it should be alphabetical order.


3
  • 4
    thanks, but as I mentioned the problem is not the alphabet. How are _ and - treated? How is hierarchy? And where can I find the official way it is sorted? Commented May 19, 2016 at 19:14
  • 1
    @user50224 And where can I find the official way it is sorted? in the open source code, of course. Commented Oct 19, 2016 at 18:32
  • @underscore_d By extension: And how do I change the way it is sorted? By forking Gnome, of course. Commented Jul 7, 2020 at 18:47

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.