diff --git a/thunar/thunar-file.c b/thunar/thunar-file.c index 1171527..941299a 100644 --- a/thunar/thunar-file.c +++ b/thunar/thunar-file.c @@ -3113,12 +3113,17 @@ static gint compare_by_name_using_number (const gchar *ap, const gchar *bp) { - guint anum; - guint bnum; + gsize anum; + gsize bnum; - /* determine the numbers in ap and bp */ - anum = strtoul (ap, NULL, 10); - bnum = strtoul (bp, NULL, 10); + /* up until now the numbers match. Now compare the numbers by digit + * count, the longest number is the largest. If the length are equal + * just compare this digit. + */ + + /* determine digit count in ap and bp */ + anum = strspn (ap, "0123456789"); + bnum = strspn (bp, "0123456789"); /* compare the numbers */ if (anum < bnum) @@ -3126,11 +3131,10 @@ compare_by_name_using_number (const gchar *ap, else if (anum > bnum) return 1; - /* the numbers are equal, and so the higher first digit should - * be sorted first, i.e. 'file10' before 'file010', since we - * also sort 'file10' before 'file011'. + /* the numbers are equal in length, and so the lower first digit should + * be sorted first. */ - return (*bp - *ap); + return (*ap - *bp); }