From a759f975089d746b9ae0494742ea9f43770792c9 Mon Sep 17 00:00:00 2001 From: sshakndr Date: Tue, 25 Mar 2025 11:48:16 +0700 Subject: [PATCH] fix(ruby): sort files by modification time. Fix Bug 73654 --- .../ruby/app/models/document_helper.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/document_helper.rb b/web/documentserver-example/ruby/app/models/document_helper.rb index 912a0fe8..f4ac466e 100755 --- a/web/documentserver-example/ruby/app/models/document_helper.rb +++ b/web/documentserver-example/ruby/app/models/document_helper.rb @@ -169,11 +169,13 @@ class DocumentHelper next if e.eql?('..') next if File.directory?(File.join(directory, e)) # if the element is a directory, skip it - arr.push(e) # push the file to the array + file_path = File.join(directory, e) + arr.push([e, File.mtime(file_path)]) # push the file name and its modification time to the array end end - arr + arr.sort_by { |_, mtime| -mtime.to_i } # rubocop:disable Lint/NumberConversion + .map(&:first) end # create file meta information