about summary refs log tree commit diff stats
path: root/code
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2009-07-18 23:17:28 +0200
committerhut <hut@lavabit.com>2009-07-18 23:17:28 +0200
commit2a415f9058842499a7572cd1c1148004c1e8240d (patch)
treebf79f8f7a31c539f4b74e1543a7eddedb03b87b1 /code
parentbc44357ac9e50100539025f1cdd802933c403e63 (diff)
downloadranger-2a415f9058842499a7572cd1c1148004c1e8240d.tar.gz
improved sorting a bit, (DRY, threadsafe)
Diffstat (limited to 'code')
-rw-r--r--code/directory.rb11
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