summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2010-10-02 01:53:20 +0200
committerhut <hut@lavabit.com>2010-10-02 01:53:20 +0200
commitba16a2e43a71f3ee1a66ffaf1613bb1cce1665fc (patch)
tree58549e6a2b4e374c4f9835152f8119efa2688f55
parent9b3d4455ad389138c9b63d5153d03c4cfbee0672 (diff)
downloadranger-ba16a2e43a71f3ee1a66ffaf1613bb1cce1665fc.tar.gz
fsobject.fsobject: Fixed order in natural sort
Before:
foo2.txt
foo3.txt
foo.txt

After:
foo.txt
foo2.txt
foo3.txt
-rw-r--r--ranger/fsobject/fsobject.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/ranger/fsobject/fsobject.py b/ranger/fsobject/fsobject.py
index 63a64029..a52dac91 100644
--- a/ranger/fsobject/fsobject.py
+++ b/ranger/fsobject/fsobject.py
@@ -28,7 +28,7 @@ from ranger.ext.spawn import spawn
 from ranger.ext.lazy_property import lazy_property
 from ranger.ext.human_readable import human_readable
 
-_extract_number_re = re.compile(r'(\d+)')
+_extract_number_re = re.compile(r'([^0-9]?)(\d*)')
 
 class FileSystemObject(MimeTypeAware, FileManagerAware):
 	(basename,
@@ -103,12 +103,12 @@ class FileSystemObject(MimeTypeAware, FileManagerAware):
 
 	@lazy_property
 	def basename_natural(self):
-		return [int(c) if c.isdigit() else c \
+		return [int(c) if c.isdigit() else c or 0 \
 			for c in _extract_number_re.split(self.basename)]
 
 	@lazy_property
 	def basename_natural_lower(self):
-		return [int(c) if c.isdigit() else c \
+		return [int(c) if c.isdigit() else c or 0 \
 			for c in _extract_number_re.split(self.basename_lower)]
 
 	def __str__(self):