code: def _sort(self, session_groups):
      
  
      # Sort by session_group name so we have a deterministic order.
      session_groups.sort(key=operator.attrgetter('name'))
      # Sort by lexicographical order of the _request.col_params whose order
      # is not ORDER_UNSPECIFIED. The first such column is the primary sorting
      # key, the second is the secondary sorting key, etc. To achieve that we
      # need to iterate on these columns in reverse order (thus the primary key
      # is the key used in the last sort).
      for col_param, extractor in reversed(list(zip(self._request.col_params,
                                                    self._extractors))):
        if col_param.order == api_pb2.ORDER_UNSPECIFIED:
          continue
        if col_param.order == api_pb2.ORDER_ASC:
          session_groups.sort(
              key=_create_key_func(
                  extractor,
                  none_is_largest=not col_param.missing_values_first))
        elif col_param.order == api_pb2.ORDER_DESC:
          session_groups.sort(
              key=_create_key_func(
                  extractor,
                  none_is_largest=col_param.missing_values_first),
              reverse=True)
        else:
          raise error.HParamsError('Unknown col_param.order given: %s' %
                                   col_param)
docs: Sorts 'session_groups' in place according to _request.col_params.