From 41d627e3f9d80ec2e1e444762e720fd964fa8db4 Mon Sep 17 00:00:00 2001 From: Chris Hill Date: Sat, 13 Feb 2016 16:57:09 +0000 Subject: [PATCH] natural sort lower case --- openlp/plugins/songs/lib/mediaitem.py | 2 +- tests/functional/openlp_plugins/songs/test_mediaitem.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 87a3d81d1..9dd4e29f8 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -699,7 +699,7 @@ class SongMediaItem(MediaManagerItem): Return a tuple by which s is sorted. :param s: A string value from the list we want to sort. """ - return [int(text) if text.isdecimal() else text + return [int(text) if text.isdecimal() else text.lower() for text in re.split('(\d+)', s)] def search(self, string, show_error): diff --git a/tests/functional/openlp_plugins/songs/test_mediaitem.py b/tests/functional/openlp_plugins/songs/test_mediaitem.py index 2b586a96a..d09f5b76e 100644 --- a/tests/functional/openlp_plugins/songs/test_mediaitem.py +++ b/tests/functional/openlp_plugins/songs/test_mediaitem.py @@ -427,7 +427,7 @@ class TestMediaItem(TestCase, TestMixin): sort_key_result = self.media_item._natural_sort_key(string_sort_key) # THEN: We should get back a tuple split on integers - self.assertEqual(sort_key_result, ['A', 1, 'B', 12, 'C']) + self.assertEqual(sort_key_result, ['a', 1, 'b', 12, 'c']) def build_remote_search_test(self): """