diff options
author | hut <hut@lavabit.com> | 2009-07-18 23:17:28 +0200 |
---|---|---|
committer | hut <hut@lavabit.com> | 2009-07-18 23:17:28 +0200 |
commit | 2a415f9058842499a7572cd1c1148004c1e8240d (patch) | |
tree | bf79f8f7a31c539f4b74e1543a7eddedb03b87b1 /code | |
parent | bc44357ac9e50100539025f1cdd802933c403e63 (diff) | |
download | ranger-2a415f9058842499a7572cd1c1148004c1e8240d.tar.gz |
improved sorting a bit, (DRY, threadsafe)
Diffstat (limited to 'code')
-rw-r--r-- | code/directory.rb | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/code/directory.rb b/code/directory.rb index c3ab2fbe..92782907 100644 --- a/code/directory.rb +++ b/code/directory.rb @@ -205,8 +205,6 @@ class Directory def sort_sub(x, y) case Option.sort - when :name - x.basename <=> y.basename when :ext x.ext <=> y.ext when :type @@ -217,13 +215,13 @@ class Directory x.ctime <=> y.ctime when :mtime x.mtime <=> y.mtime - else + when :name, Object x.basename <=> y.basename end end def sort() - @files = @files.sort {|x,y| + files = @files.sort {|x,y| if Option.list_dir_first if x.dir? if y.dir? then sort_sub(x, y) else -1 end @@ -234,8 +232,9 @@ class Directory sort_sub(x, y) end } - @files.reverse! if Option.sort_reverse - @files_raw = @files.map{|x| x.to_s} + files.reverse! if Option.sort_reverse + @files_raw = files.map{|x| x.to_s} + @files = files end end |