# FINDER - macOS - sort by Name

**URL:** <https://ifnotnil.com/t/finder-macos-sort-by-name/1375>\
**Category:** Other\
**Created:** [29 November 2020 23:56 UTC](https://ifnotnil.com/t/finder-macos-sort-by-name/1375 "2020-11-29T23:56:21Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![DaveS](https://ifnotnil.com/user_avatar/ifnotnil.com/daves/32/79_2.png) [@DaveS](https://ifnotnil.com/u/DaveS)\
**Post date:** [29 November 2020 23:56 UTC](https://ifnotnil.com/t/finder-macos-sort-by-name/1375/1 "2020-11-29T23:56:21Z")

</div>

Has anyone else noticed when you tell Finder to “sort by name” its strange?  
I have 255 files named “file$XX.dat” where XX is 00 to FF  
now I don’t expect them to be sorted in NUMERIC order…

but I don’t expect THIS order

```auto
$5E $5F $06 $6A $6B $07 $08 $09 $10 ..... $19 $21 ...$33 $40

```

I would expect them to be sort by the alphanumeric name

```auto
$00 ... $0F
$10....$1F
etc.

```

---

<div class="post-metadata">

**Author:** ![npalardy](https://ifnotnil.com/user_avatar/ifnotnil.com/npalardy/32/10_2.png) [@npalardy](https://ifnotnil.com/u/npalardy)\
**Post date:** [30 November 2020 00:44 UTC](https://ifnotnil.com/t/finder-macos-sort-by-name/1375/2 "2020-11-30T00:44:42Z")

</div>

how truly curious

---

<div class="post-metadata">

**Author:** ![DaveS](https://ifnotnil.com/user_avatar/ifnotnil.com/daves/32/79_2.png) [@DaveS](https://ifnotnil.com/u/DaveS)\
**Post date:** [30 November 2020 00:58 UTC](https://ifnotnil.com/t/finder-macos-sort-by-name/1375/3 "2020-11-30T00:58:48Z")

</div>

yes, yes it is…

not only that but the Xcode Asset Catalog, sorts them the same strange way

---

<div class="post-metadata">

**Author:** ![npalardy](https://ifnotnil.com/user_avatar/ifnotnil.com/npalardy/32/10_2.png) [@npalardy](https://ifnotnil.com/u/npalardy)\
**Post date:** [30 November 2020 03:18 UTC](https://ifnotnil.com/t/finder-macos-sort-by-name/1375/4 "2020-11-30T03:18:52Z")

</div>

as does this method I wrote about “Sorting like finder” way back

> **[Sort like Finder – Writings from the sticks](https://www.great-white-software.com/blog/2019/10/07/sort-like-finder/)**

Its really curious since its not considering the $XX part as numeric OR lexical  
Very odd

---

<div class="post-metadata">

**Author:** ![DaveS](https://ifnotnil.com/user_avatar/ifnotnil.com/daves/32/79_2.png) [@DaveS](https://ifnotnil.com/u/DaveS)\
**Post date:** [30 November 2020 06:08 UTC](https://ifnotnil.com/t/finder-macos-sort-by-name/1375/5 "2020-11-30T06:08:02Z")

</div>

but in any comparison method… ."$06" is LESS than “$5E” … ☹

It makes it really hard to find a file (via EyeBall Reader 1.0) when they are not in the order expected.

---

<div class="post-metadata">

**Author:** ![samRowlands](https://ifnotnil.com/user_avatar/ifnotnil.com/samrowlands/32/121_2.png) [@samRowlands](https://ifnotnil.com/u/samRowlands)\
**Post date:** [30 November 2020 06:10 UTC](https://ifnotnil.com/t/finder-macos-sort-by-name/1375/6 "2020-11-30T06:10:13Z")

</div>

Unless it ignores the $ and the leading zero.

---

<div class="post-metadata">

**Author:** ![DaveS](https://ifnotnil.com/user_avatar/ifnotnil.com/daves/32/79_2.png) [@DaveS](https://ifnotnil.com/u/DaveS)\
**Post date:** [30 November 2020 06:23 UTC](https://ifnotnil.com/t/finder-macos-sort-by-name/1375/7 "2020-11-30T06:23:02Z")

</div>

true… but its still “wrong”

---

<div class="post-metadata">

**Author:** ![DaveS](https://ifnotnil.com/user_avatar/ifnotnil.com/daves/32/79_2.png) [@DaveS](https://ifnotnil.com/u/DaveS)\
**Post date:** [30 November 2020 06:31 UTC](https://ifnotnil.com/t/finder-macos-sort-by-name/1375/8 "2020-11-30T06:31:57Z")

</div>

I have found articles that discuss this (or something similar) and eludes to a difference between “sort by” and “arrange by”… but none of the “solutions” seem to be able to be applied in Catalina

---

<div class="post-metadata">

**Author:** ![samRowlands](https://ifnotnil.com/user_avatar/ifnotnil.com/samrowlands/32/121_2.png) [@samRowlands](https://ifnotnil.com/u/samRowlands)\
**Post date:** [30 November 2020 07:26 UTC](https://ifnotnil.com/t/finder-macos-sort-by-name/1375/9 "2020-11-30T07:26:03Z")

</div>

If that is the case, someone (probably an intern or someone with reduced experience) thinks that it is right \<shakesHead/\>

---

<div class="post-metadata">

**Author:** ![MonkeybreadSoftware](https://ifnotnil.com/user_avatar/ifnotnil.com/monkeybreadsoftware/32/451_2.png) [@MonkeybreadSoftware](https://ifnotnil.com/u/MonkeybreadSoftware)\
**Post date:** [30 November 2020 08:46 UTC](https://ifnotnil.com/t/finder-macos-sort-by-name/1375/10 "2020-11-30T08:46:40Z")

</div>

I also have [NSStringArraySortMBS](https://www.monkeybreadsoftware.net/global-nsstringarraysortmbs.shtml) in the plugin, which sorts a Xojo array using [NSStringCompareMBS](https://www.monkeybreadsoftware.net/global-nsstringcomparembs.shtml), which also uses Apple’s sorting including the sort by number option.

Seems like it doesn’t work for hex numbers, but it works fine for numbers.

---

<div class="post-metadata">

**Author:** ![npalardy](https://ifnotnil.com/user_avatar/ifnotnil.com/npalardy/32/10_2.png) [@npalardy](https://ifnotnil.com/u/npalardy)\
**Post date:** [30 November 2020 14:56 UTC](https://ifnotnil.com/t/finder-macos-sort-by-name/1375/11 "2020-11-30T14:56:14Z")

</div>

> [@DaveS](#):
>
> but in any comparison method… .“$06” is LESS than “$5E” … ☹

Yeah I cant figure what they are doing that things come out the ay they are  
Its not obvious

---

<div class="post-metadata">

**Author:** ![DaveS](https://ifnotnil.com/user_avatar/ifnotnil.com/daves/32/79_2.png) [@DaveS](https://ifnotnil.com/u/DaveS)\
**Post date:** [30 November 2020 15:30 UTC](https://ifnotnil.com/t/finder-macos-sort-by-name/1375/12 "2020-11-30T15:30:32Z")

</div>

Christian… its not a “hex” number it is two alphanumeric characters. Finder should not be attempting to derive a “context” from a file name

---

<div class="post-metadata">

**Author:** ![Meestor\_X](https://ifnotnil.com/user_avatar/ifnotnil.com/meestor_x/32/567_2.png) [@Meestor\_X](https://ifnotnil.com/u/Meestor_X)\
**Post date:** [1 December 2020 23:57 UTC](https://ifnotnil.com/t/finder-macos-sort-by-name/1375/13 "2020-12-01T23:57:21Z")

</div>

Looks to me like:

1. Strip the non-numeric part of the string
2. Take a Val() of the remaining number and order it by that.

---

<div class="post-metadata">

**Author:** ![DaveS](https://ifnotnil.com/user_avatar/ifnotnil.com/daves/32/79_2.png) [@DaveS](https://ifnotnil.com/u/DaveS)\
**Post date:** [1 December 2020 23:59 UTC](https://ifnotnil.com/t/finder-macos-sort-by-name/1375/14 "2020-12-01T23:59:13Z")

</div>

This is not sorting filenames using Xojo… it is sorting them in Finder… so no manipulation of the filename is possible

---

<div class="post-metadata">

**Author:** ![Meestor\_X](https://ifnotnil.com/user_avatar/ifnotnil.com/meestor_x/32/567_2.png) [@Meestor\_X](https://ifnotnil.com/u/Meestor_X)\
**Post date:** [2 December 2020 00:02 UTC](https://ifnotnil.com/t/finder-macos-sort-by-name/1375/15 "2020-12-02T00:02:40Z")

</div>

> [@DaveS](#):
>
> This is not sorting filenames using Xojo… it is sorting them in Finder… so no manipulation of the filename is possible

I get that. Just my take on what MacOS is doing “under the hood”. No idea why…  
Are you seeing the same thing if the files don’t have the “$” prefix?

---

<div class="post-metadata">

**Author:** ![DaveS](https://ifnotnil.com/user_avatar/ifnotnil.com/daves/32/79_2.png) [@DaveS](https://ifnotnil.com/u/DaveS)\
**Post date:** [2 December 2020 00:50 UTC](https://ifnotnil.com/t/finder-macos-sort-by-name/1375/16 "2020-12-02T00:50:52Z")

</div>

I created another set of files that used $xxx where xxx was completely numeric, and those sorted correctly

---

<div class="post-metadata">

**Author:** ![Tim](https://ifnotnil.com/user_avatar/ifnotnil.com/tim/32/13_2.png) [@Tim](https://ifnotnil.com/u/Tim)\
**Post date:** [2 December 2020 01:32 UTC](https://ifnotnil.com/t/finder-macos-sort-by-name/1375/17 "2020-12-02T01:32:04Z")

</div>

You know what it looks like to me?

It looks like handling designed to accommodate designers, these weird people who don’t source control their work, who might name a document:

```auto
Doc-a
Doc-a1
Doc-a1-good
Doc-a1-new-good

```

and so on…

---

<div class="post-metadata">

**Author:** ![DaveS](https://ifnotnil.com/user_avatar/ifnotnil.com/daves/32/79_2.png) [@DaveS](https://ifnotnil.com/u/DaveS)\
**Post date:** [2 December 2020 01:47 UTC](https://ifnotnil.com/t/finder-macos-sort-by-name/1375/18 "2020-12-02T01:47:22Z")

</div>

> [@DaveS](#):
>
> `$5E $5F $06 $6A $6B $07 $08 $09 $10 ..... $19 $21 ...$33 $40`

That doesn’t explain seeing this order…

---

<div class="post-metadata">

**Author:** ![npalardy](https://ifnotnil.com/user_avatar/ifnotnil.com/npalardy/32/10_2.png) [@npalardy](https://ifnotnil.com/u/npalardy)\
**Post date:** [2 December 2020 01:58 UTC](https://ifnotnil.com/t/finder-macos-sort-by-name/1375/19 "2020-12-02T01:58:47Z")

</div>

thats about what I thought it might be doing but that would give something different than

$5E $5F $06 $6A $6B $07 $08 $09 $10 … $19 $21 …$33 $40

as the $06 $07 $08 $09 would be closer to the beginning of the list

Its really a weird organization

---

<div class="post-metadata">

**Author:** ![Meestor\_X](https://ifnotnil.com/user_avatar/ifnotnil.com/meestor_x/32/567_2.png) [@Meestor\_X](https://ifnotnil.com/u/Meestor_X)\
**Post date:** [2 December 2020 02:06 UTC](https://ifnotnil.com/t/finder-macos-sort-by-name/1375/20 "2020-12-02T02:06:13Z")

</div>

Did you guys not see my earlier reply? 🕶

MacOS treats numbers as a single character for sorting.

The list is sorted exactly the way MacOS was designed to. Stupidly. But that’s the way it’s done it for like 20 years.

> **[Sort order of alphanumeric file names in … - Apple Community](https://discussions.apple.com/thread/1317720)**

[Next page](https://ifnotnil.com/t/finder-macos-sort-by-name/1375.md?page=2)
