Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Dir.glob guarantee the order?

Tags:

ruby

Ruby docs don't mention this.

Does Dir.glob("*") guarantee the order of the files it returns, or do I need to sort them myself to be certain?

like image 711
Ali Lown Avatar asked Jun 02 '11 21:06

Ali Lown


2 Answers

No. Not if you're moving across OSes: http://rubyforge.org/tracker/index.php?func=detail&aid=12795&group_id=426&atid=1698

like image 79
Tim Snowhite Avatar answered Oct 16 '22 12:10

Tim Snowhite


If the docs don't say it, then there is no guarantee, and you need to sort it for yourself. Even if it works in your current ruby, it may not in your next.

like image 30
Mori Avatar answered Oct 16 '22 14:10

Mori