def listbox_sort_by_name(row1, row2, user_data): """ Sort function for listbox Returns : < 0 if row1 should be before row2, 0 if they are equal and > 0 otherwise WARNING: IF LAYOUT IS CHANGED IN fill_listbox THEN THIS SHOULD BE CHANGED ACCORDINGLY. """ box1 = row1.get_child() label1 = box1.get_children()[1] box2 = row2.get_child() label2 = box2.get_children()[1] text = [label1.get_text(), label2.get_text()] # sorted_text = misc.sort_list(text, self.settings.get("locale")) sorted_text = misc.sort_list(text) # If strings are already well sorted return < 0 if text[0] == sorted_text[0]: return -1 # Strings must be swaped, return > 0 return 1