# Find.find reversed order on MacOSX Snow Leopard

**URL:** <https://www.ruby-forum.com/t/find-find-reversed-order-on-macosx-snow-leopard/177538>\
**Category:** Ruby\
**Created:** [October 19, 2009, 11:19pm UTC](https://www.ruby-forum.com/t/find-find-reversed-order-on-macosx-snow-leopard/177538 "2009-10-19T23:19:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![raphael](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/edb3f5/32.png) [@raphael](https://www.ruby-forum.com/u/raphael)\
**Post date:** [October 19, 2009, 11:19pm UTC](https://www.ruby-forum.com/t/find-find-reversed-order-on-macosx-snow-leopard/177538/1 "2009-10-19T23:19:48Z")

</div>

Hi all,

I just found out that the following code yields the directory listing in  
reverse alphanumerical order on Snow Leopard (10.6.1). This is with the  
out-of-the-box ruby install.

require ‘find’  
Find.find ‘/Library/Preferences/’ do |x| puts x end

On MacOSX 10.5 Leopard, it yielded the listing in either default system  
order, or alphanumerical order, I don’t remember.

Is it expected behaviour and what can I do to restore the previous one?

thanks  
RaphaÃ«l

---

<div class="post-metadata">

**Author:** ![raphael](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/edb3f5/32.png) [@raphael](https://www.ruby-forum.com/u/raphael)\
**Post date:** [October 20, 2009, 12:31am UTC](https://www.ruby-forum.com/t/find-find-reversed-order-on-macosx-snow-leopard/177538/2 "2009-10-20T00:31:32Z")

</div>

On 20 Oct, 2009, at 12:19 AM, Raphaël Marmier wrote:

> On MacOSX 10.5 Leopard, it yielded the listing in either default  
> system  
> order, or alphanumerical order, I don’t remember.

Just tried that on 10.5 and it still gives reverse alphanumerical order.

[pokui@mbp-pjo:~]$ sw\_vers  
ProductName: Mac OS X  
ProductVersion: 10.5.8  
BuildVersion: 9L30  
[pokui@mbp-pjo:~]$ ruby -r ‘find’ -e ‘Find.find “/Library/  
Preferences/” do |x| puts x end’  
/Library/Preferences/  
/Library/Preferences/SystemConfiguration  
…  
…  
…  
/Library/Preferences/com.apple.AppleFileServer.plist  
/Library/Preferences/com.apple.alf.plist  
/Library/Preferences/com.apple.AirPortBaseStationAgent.launchd  
/Library/Preferences/.GlobalPreferences.plist  
[pokui@mbp-pjo:~]$

---

<div class="post-metadata">

**Author:** ![raphael](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/edb3f5/32.png) [@raphael](https://www.ruby-forum.com/u/raphael)\
**Post date:** [October 20, 2009, 9:39am UTC](https://www.ruby-forum.com/t/find-find-reversed-order-on-macosx-snow-leopard/177538/3 "2009-10-20T09:39:55Z")

</div>

I understand now that any sort performed on a find() would delay it  
until directory traversal is complete.

Thanks for your answers.

RaphaÃ«l

Yukihiro M. wrote:

> Hi,
> 
> In message “Re: Find.find reversed order on MacOSX Snow Leopard”  
> on Tue, 20 Oct 2009 06:19:50 +0900, Raphaï¿½l Marmier  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:
> 
> |I just found out that the following code yields the directory listing in  
> |reverse alphanumerical order on Snow Leopard (10.6.1). This is with the  
> |out-of-the-box ruby install.
> 
> |Is it expected behaviour and what can I do to restore the previous one?
> 
> Find.find does no sorting. It traverse through paths in the order  
> given from underlying OS. If you see the order changed on Snow  
> Leopard, it must be their _fault_. If you really need the specific  
> order, you have to gather paths first, then sort them before process.
> 
> ```
> matz.
> 
> ```

---

<div class="post-metadata">

**Author:** ![raphael](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/edb3f5/32.png) [@raphael](https://www.ruby-forum.com/u/raphael)\
**Post date:** [October 20, 2009, 12:50am UTC](https://www.ruby-forum.com/t/find-find-reversed-order-on-macosx-snow-leopard/177538/4 "2009-10-20T00:50:16Z")

</div>

Hi,

In message “Re: Find.find reversed order on MacOSX Snow Leopard”  
on Tue, 20 Oct 2009 06:19:50 +0900, Raphaël Marmier  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:

|I just found out that the following code yields the directory listing in  
|reverse alphanumerical order on Snow Leopard (10.6.1). This is with the  
|out-of-the-box ruby install.

|Is it expected behaviour and what can I do to restore the previous one?

Find.find does no sorting. It traverse through paths in the order  
given from underlying OS. If you see the order changed on Snow  
Leopard, it must be their _fault_. If you really need the specific  
order, you have to gather paths first, then sort them before process.

```
          matz.

```
