Issue #8709 has been updated by byroot (Jean Boussier).


For what it's worth I also think it should return a sorted array, because:

  - Pretty much any rubyist I know have been been bitten by this at least once.
  - Many experienced rubyist end up always writing `Dir[patten].sort`
  - It's particularly prevalent because the "develop on OSX, deploy on Linux" combo is very popular.

If the performance impact is a concern, I think an extra keyword argument could be added: `glob( pattern, [flags], [base: path], [sort: true] )`, this way you can avoid the performance impact if you know that you don't need it.

----------------------------------------
Feature #8709: Dir.glob should return sorted file list
https://bugs.ruby-lang.org/issues/8709#change-83820

* Author: tommorris (Tom Morris)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
On OS X, Dir.glob and Dir[] return an ordered list of files.

On Ubuntu Linux, they do not and one must manually sort them.

Returning a list of files that isn't in order fails the Principle of Least Astonishment.

I attach a unit test to demonstrate ideal behaviour.

---Files--------------------------------
globtest.rb (454 Bytes)


-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>