From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS4713 221.184.0.0/13 X-Spam-Status: No, score=-2.8 required=3.0 tests=AWL,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=no autolearn_force=no version=3.4.2 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id 4421E1F885 for ; Sat, 11 Jan 2020 11:33:45 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 22C231209DA; Sat, 11 Jan 2020 20:33:30 +0900 (JST) Received: from o1678948x4.outbound-mail.sendgrid.net (o1678948x4.outbound-mail.sendgrid.net [167.89.48.4]) by neon.ruby-lang.org (Postfix) with ESMTPS id C26AB1209D3 for ; Sat, 11 Jan 2020 20:33:27 +0900 (JST) Received: by filterdrecv-p3iad2-57f487d66-rgh5v with SMTP id filterdrecv-p3iad2-57f487d66-rgh5v-18-5E19B28F-14 2020-01-11 11:33:35.277839187 +0000 UTC m=+2198810.681455203 Received: from herokuapp.com (unknown [54.224.129.129]) by ismtpd0026p1iad2.sendgrid.net (SG) with ESMTP id dWPNTDnGT-CWxOMgKecRvA for ; Sat, 11 Jan 2020 11:33:35.287 +0000 (UTC) Date: Sat, 11 Jan 2020 11:33:35 +0000 (UTC) From: eregontp@gmail.com Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 72445 X-Redmine-Project: ruby-master X-Redmine-Issue-Id: 8709 X-Redmine-Issue-Author: tommorris X-Redmine-Sender: Eregon X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-SG-EID: =?us-ascii?Q?KippOI8ZHtTweq7XfQzW93937kJ4QNWwSBuHnaMEcr3T4aKc5u440X1ZECzeFU?= =?us-ascii?Q?Ntgx1BLa2p5EHvOQcD8f1OOc2fW8SetPhn=2FW1vn?= =?us-ascii?Q?hBfP6Tb6a5VcoA6bcLHKai=2FlmxwjbbWXB6UY4dn?= =?us-ascii?Q?FjA4ibNZhDvwtkTRGkafXMlsSoyo9ee5QOJG69M?= =?us-ascii?Q?b7HqvRXDaL+vepaf2PO30AOGryKoQVIIV1+u6r6?= =?us-ascii?Q?BDMZ3HMnT+elEMaCk=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 96782 Subject: [ruby-core:96782] [Ruby master Feature#8709] Dir.glob should return sorted file list X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #8709 has been updated by Eregon (Benoit Daloze). Here are some benchmark results in the ruby repository: ``` $ ruby -e 'p Dir["**/*"].size' 12171 $ ruby -rbenchmark -e '10.times { p Benchmark.realtime { Dir["**/*"] } }' 0.017877419999422273 0.015390422999189468 0.015255956001055893 0.015021605999208987 0.015777969998453045 0.015484851002838695 0.016179073001694633 0.015210424000542844 0.015358253996964777 0.014319942998554325 $ ruby -rbenchmark -e '10.times { p Benchmark.realtime { Dir["**/*"].sort } }' 0.017600111998035572 0.017109740001615137 0.017832364999776473 0.01726310600133729 0.018130796997866128 0.01659841600121581 0.018173008000303525 0.017528833999676863 0.017515739000373287 0.01770434499849216 ``` So a bit slower but we can likely optimize further if desired. ---------------------------------------- Feature #8709: Dir.glob should return sorted file list https://bugs.ruby-lang.org/issues/8709#change-83776 * 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/