nodes: 0, module; 1, function_definition; 2, function_name:sort; 3, parameters; 4, block; 5, identifier:self; 6, identifier:by; 7, default_parameter; 8, expression_statement; 9, if_statement; 10, expression_statement; 11, return_statement; 12, identifier:desc; 13, False; 14, comment:"""Sorts by given property or function, ascending or descending order.
  
          Parameters
          ----------
          by : str or callable
              If string, property by which to sort.
              If callable, it should receive a GeoFeature a return a value by which to sort.
          desc : bool, optional
              Descending sort, default to False (ascending).
  
          """; 15, call; 16, block; 17, else_clause; 18, assignment; 19, call; 20, identifier:callable; 21, argument_list; 22, expression_statement; 23, block; 24, identifier:sorted_features; 25, call; 26, attribute; 27, argument_list; 28, identifier:by; 29, assignment; 30, function_definition; 31, identifier:sorted; 32, argument_list; 33, identifier:self; 34, identifier:__class__; 35, identifier:sorted_features; 36, identifier:key; 37, identifier:by; 38, function_name:key; 39, parameters; 40, block; 41, call; 42, keyword_argument; 43, keyword_argument; 44, identifier:feature; 45, return_statement; 46, identifier:list; 47, argument_list; 48, identifier:reverse; 49, identifier:desc; 50, identifier:key; 51, identifier:key; 52, subscript; 53, identifier:self; 54, identifier:feature; 55, identifier:by
code: def sort(self, by, desc=False):
          """Sorts by given property or function, ascending or descending order.
  
          Parameters
          ----------
          by : str or callable
              If string, property by which to sort.
              If callable, it should receive a GeoFeature a return a value by which to sort.
          desc : bool, optional
              Descending sort, default to False (ascending).
  
          """
          if callable(by):
              key = by
          else:
              def key(feature):
                  return feature[by]
  
          sorted_features = sorted(list(self), reverse=desc, key=key)
          return self.__class__(sorted_features)