code: def _sort_by(key):
      
  
      @staticmethod
      def sort_by(p_list, reverse=False):
          return sorted(
              p_list,
              key=lambda p: getattr(p, key),
              reverse=reverse,
          )
  
      return sort_by
docs: High order function for sort methods.