def _compare_menu_actions(self, lhs, rhs): """ Compare two menu actions. Actions are sorted alphabetically, but the default note, denoted by a *, is always at the top. """ # extract the action name so we can sort based on that. lhs_action_name = lhs[1] rhs_action_name = rhs[1] lhs_is_default = lhs[-1] rhs_is_default = rhs[-1] # The default action, denoted by a * in the menu, is always at the top. # Everything else is sorted alphabetically. if lhs_is_default: return -1 elif rhs_is_default: return 1 elif util.is_version_newer(lhs_action_name, rhs_action_name): return -1 elif util.is_version_older(lhs_action_name, rhs_action_name): return 1 else: return 0
def child_cmp(left, right): left_version = left.data(cls.MENU_NAME_ROLE) right_version = right.data(cls.MENU_NAME_ROLE) if util.is_version_newer(left_version, right_version): return -1 if util.is_version_older(left_version, right_version): return 1 return 0