Ticket #1684: 0004-Make-the-dictionary-sorting-a-bit-more-sensible.patch

File 0004-Make-the-dictionary-sorting-a-bit-more-sensible.patch, 932 bytes (added by sayamindu, 13 years ago)

Make the return section (dictionary sorting part) make more sense

  • src/sugar/activity/i18n.py

    From 1b600b147d76b84322376c910738b74d38b4a5ca Mon Sep 17 00:00:00 2001
    From: Sayamindu Dasgupta <sayamindu@gmail.com>
    Date: Tue, 9 Feb 2010 17:43:18 +0530
    Subject: Make the dictionary sorting a bit more sensible
    
    ---
     src/sugar/activity/i18n.py |    7 ++++---
     1 files changed, 4 insertions(+), 3 deletions(-)
    
    diff --git a/src/sugar/activity/i18n.py b/src/sugar/activity/i18n.py
    index 865928a..410bc15 100644
    a b def get_locale_path(bundle_id): 
    138138                    # Set lowest priority
    139139                    candidate_dirs[candidate_dir] = -1
    140140
    141     # Fancy way to sort the dictionary by value
    142     return sorted(candidate_dirs.iteritems(), key=lambda (k, v): (v, k), \
    143         reverse=True)[0][0]
     141    sorted_dict = sorted(candidate_dirs.iteritems(), key=lambda (k, v): \
     142        (v, k), reverse=True)
     143
     144    return sorted_dict[0][0]