Fixing Sort Order in Finder List Views

OS X users may find that filenames sort in the Finder in ways they do not expect. This is because OS X uses different sorting rules than do OS 9, Unix (including Terminal), and pre-WinXP Windows systems. Examples are digit strings and first/last markers.

Digits: A fundamental change in OS X is that strings of digits are ordered according to their numerical value (alphanumerically) rather than by each digit individually (lexicograhically). In the latter case (as in OS 9 or Terminal) a file called 11 comes before a file called 2, because 1 < 2. In OS X, file 2 comes before 11, because 2 < 11.

When a series of files has been named with digits so as to sort properly in OS 9 or Terminal, it may show up in quite a different order in OS X. If this is a problem, three possible fixes are:

a) Rename all the files to fit OS X conventions.

b) Operate on the files in Terminal or Classic.

c) Use a dimension other than name to sort the files in OS X. One possibility is the Comments field, where you can enter appropriate data and then have list view sorted according to that field.

<b>First/Last List Items: The standard way to get a file to appear at the top of the list in OS 9 is to put a space before its name, and to get it to appear at the bottom, a tilde or a bullet. In OS X both space and tilde/bullet put an item at the top of the list. To move a file name to the bottom, you can preface it with a Greek letter like mu (Option-m), omega (Option-z) or pi (Option-p).

For technical info on OS X sorting rules, see the Apple documentation:

http://developer.apple.com/documentation/MacOSX/Conceptual/BPFileSystem/Concepts /SortingRules.html

and the Unicode sorting list (which seems to differ somewhat from what Apple is using):

http://www.unicode.org/Public/UCA/latest/allkeys.txt

In non-Unicode applications, sort order is also determined in System Preferences/International/Language/Customize Sorting.

If you want OS9/Classic to sort like OS X, you can try the program Natural Order:

http://www.naturalordersort.org/

If you want Terminal to sort like OS X, use ls -n when files begin with numbers, and sort -n (plus some additional info, see the man page) otherwise.

OS 9/Terminal sorting will work like OS X's if you make sure all digit strings have equal length, using zeros to pad the shorter numbers, e.g. 02, 11.

Posted on Jan 27, 2005 9:52 AM

Reply
2 replies

Jan 28, 2005 12:22 PM in response to Tom Gewecke

OS X users may find that filenames sort in the Finder in ways they do not expect. This is because OS X uses different sorting rules than do OS 9, Unix (including Terminal), and pre-WinXP Windows systems. Examples are digit strings and first/last markers.

Digits: A fundamental change in OS X is that strings of digits are ordered according to their numerical value (alphanumerically) rather than by each digit individually (lexicograhically). In the latter case (as in OS 9 or Terminal) a file called 11 comes before a file called 2, because 1 < 2. In OS X, file 2 comes before 11, because 2 < 11.

When a series of files has been named with digits so as to sort properly in OS 9 or Terminal, it may show up in quite a different order in OS X. If this is a problem, three possible fixes are:

a) Rename all the files to fit OS X conventions.

b) Operate on the files in Terminal or Classic.

c) Use a dimension other than name to sort the files in OS X. One possibility is the Comments field, where you can enter appropriate data and then have list view sorted according to that field.

<b>First/Last List Items: The standard way to get a file to appear at the top of the list in OS 9 is to put a space before its name, and to get it to appear at the bottom, a tilde or a bullet. In OS X both space and tilde/bullet put an item at the top of the list. To move a file name to the bottom, you can preface it with a Greek letter like mu (Option-m), omega (Option-z) or pi (Option-p).

For technical info on OS X sorting rules, see the Apple documentation and the Unicode sorting list (which seems to differ somewhat from what Apple is using).

In non-Unicode applications, sort order is also determined in System Preferences/International/Language/Customize Sorting.

If you want OS9/Classic to sort like OS X, you can try the program Natural Order.

If you want Terminal to sort like OS X, use sort -n +POS1 -POS2. Do "man sort" in Terminal for details of how this works.

OS 9/Terminal sorting will work like OS X's if you make sure all digit strings have equal length, using zeros to pad the shorter numbers, e.g. 02, 11.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Fixing Sort Order in Finder List Views

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.