nodes: 0, module; 1, function_definition; 2, function_name:sortedSemver; 3, parameters; 4, block; 5, identifier:versions; 6, default_parameter; 7, expression_statement; 8, if_statement; 9, identifier:sort; 10, string:"asc"; 11, comment:"""Semantically sort the list of version Numbers"""; 12, boolean_operator; 13, block; 14, else_clause; 15, identifier:versions; 16, call; 17, if_statement; 18, block; 19, identifier:isinstance; 20, argument_list; 21, identifier:PY2; 22, block; 23, else_clause; 24, raise_statement; 25, identifier:versions; 26, tuple; 27, return_statement; 28, block; 29, call; 30, identifier:list; 31, identifier:tuple; 32, call; 33, import_from_statement; 34, return_statement; 35, identifier:TypeError; 36, argument_list; 37, identifier:sorted; 38, argument_list; 39, dotted_name; 40, dotted_name; 41, call; 42, string:"Invaild Versions, a list or tuple is right."; 43, identifier:versions; 44, keyword_argument; 45, keyword_argument; 46, identifier:functools; 47, identifier:cmp_to_key; 48, identifier:sorted; 49, argument_list; 50, identifier:cmp; 51, attribute; 52, identifier:reverse; 53, conditional_expression:True if sort.upper() == "DESC" else False; 54, identifier:versions; 55, keyword_argument; 56, keyword_argument; 57, identifier:semver; 58, identifier:compare; 59, True; 60, comparison_operator:sort.upper() == "DESC"; 61, False; 62, identifier:key; 63, call; 64, identifier:reverse; 65, conditional_expression:True if sort.upper() == "DESC" else False; 66, call; 67, string:"DESC"; 68, identifier:cmp_to_key; 69, argument_list; 70, True; 71, comparison_operator:sort.upper() == "DESC"; 72, False; 73, attribute; 74, argument_list; 75, attribute; 76, call; 77, string:"DESC"; 78, identifier:sort; 79, identifier:upper; 80, identifier:semver; 81, identifier:compare; 82, attribute; 83, argument_list; 84, identifier:sort; 85, identifier:upper
code: def sortedSemver(versions, sort="asc"):
      """Semantically sort the list of version Numbers"""
      if versions and isinstance(versions, (list, tuple)):
          if PY2:
              return sorted(versions, cmp=semver.compare, reverse=True if sort.upper() == "DESC" else False)
          else:
              from functools import cmp_to_key
              return sorted(versions, key=cmp_to_key(semver.compare), reverse=True if sort.upper() == "DESC" else False)
      else:
          raise TypeError("Invaild Versions, a list or tuple is right.")