From 9200e01c56e4212b189bed5b9ff18c9078f8b704 Mon Sep 17 00:00:00 2001 From: Brian Matherly Date: Tue, 18 Jul 2006 02:59:18 +0000 Subject: [PATCH] * src/plugins/NarrativeWeb.py: fix name sorting in Windows (bug #236) svn: r7037 --- ChangeLog | 1 + src/plugins/NarrativeWeb.py | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index bd8c117c0..c7c51415b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,6 @@ 2006-07-17 Brian Matherly * src/plugins/NarrativeWeb.py: typo + * src/plugins/NarrativeWeb.py: fix name sorting in Windows (bug #236) 2006-07-16 Alex Roitman * src/DisplayTabs/_GalleryTab.py (GalleryTab.build_interface): diff --git a/src/plugins/NarrativeWeb.py b/src/plugins/NarrativeWeb.py index a2d70f768..ed16dee59 100644 --- a/src/plugins/NarrativeWeb.py +++ b/src/plugins/NarrativeWeb.py @@ -2734,14 +2734,26 @@ def sort_people(db,handle_list): sorted_lists = [] temp_list = sname_sub.keys() - temp_list.sort(locale.strcoll) + temp_list.sort(strcoll_case_sensitive) for name in temp_list: slist = map(lambda x: (sortnames[x],x),sname_sub[name]) - slist.sort(lambda x,y: locale.strcoll(x[0],y[0])) + slist.sort(lambda x,y: strcoll_case_sensitive(x[0],y[0])) entries = map(lambda x: x[1], slist) sorted_lists.append((name,entries)) return sorted_lists +def strcoll_case_sensitive(string1,string2): + """ This function was written because string comparisons in Windows + seem to be case insensitive if the string is longer than + one character. """ + # First, compare the first character + diff = locale.strcoll(string1[0],string2[0]) + if diff == 0: + # If the first character is the same, compare the rest + diff = locale.strcoll(string1,string2) + return diff + + #------------------------------------------------------------------------ # #