From ba16a2e43a71f3ee1a66ffaf1613bb1cce1665fc Mon Sep 17 00:00:00 2001 From: hut Date: Sat, 2 Oct 2010 01:53:20 +0200 Subject: fsobject.fsobject: Fixed order in natural sort Before: foo2.txt foo3.txt foo.txt After: foo.txt foo2.txt foo3.txt --- ranger/fsobject/fsobject.py | 6 +++--- 1 file 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): -- cgit 1.4.1-2-gfad0