Sorts a list of Records by the order

 @param [Enumerable] records
   A list of Resources to sort

 @return [Enumerable]
   The sorted records

 @api semipublic
540049
def sort_records(records)
      sort_order = order.map { |direction| [ direction.target, direction.operator == :asc ] }

      records.sort_by do |record|
        sort_order.map do |(property, ascending)|
          Sort.new(record_value(record, property), ascending)
        end
      end
    end
772968
def records(self):
        
        return [self._records[i] for i in range(len(self._records))]
1123848
public static function sortRecord($records, $field, $order=true)
    {
        $new_array = array();
        $sortable_array = array();

        if (count($records) > 0) {
            foreach ($records as $k => $v) {
                if (is_array($v)) {
                    foreach ($v as $k2 => $v2) {
                        if ($k2 == $field) {
                            $sortable_array[$k] = $v2;
                        }
                    }
                } else {
                    $sortable_array[$k] = $v;
                }
            }

            switch ($order) {
                case true:
                    asort($sortable_array);
                break;
                case false:
                    arsort($sortable_array);
                break;
            }

            foreach ($sortable_array as $k => $v) {
                $new_array[$k] = $records[$k];
            }
        }

        return $new_array;
    }
1087864
public void sort(final IndexedSortable s, int p, int r) {
		int recordsPerSegment = s.recordsPerSegment();
		int recordSize = s.recordSize();
		int maxOffset = recordSize * (recordsPerSegment - 1);

		int pN = p / recordsPerSegment;
		int pO = (p % recordsPerSegment) * recordSize;

		int rN = r / recordsPerSegment;
		int rO = (r % recordsPerSegment) * recordSize;

		sortInternal(s, recordsPerSegment, recordSize, maxOffset, p, pN, pO, r, rN, rO, getMaxDepth(r - p));
	}
358841
def all(options={})
      offset = nil
      results = []
      begin
        options.merge!(:limit => LIMIT_MAX, :offset => offset)
        response = records(options)
        results += response.records
        offset = response.offset
      end until offset.nil? || offset.empty? || results.empty?
      results
    end
2733
def match_records(records)
      conditions = self.conditions
      records.select { |record| conditions.matches?(record) }
    end
1088441
protected function processRecords(array $records)
    {
        $record = new Record();
        $formatter = $this->getFormatter();
        if ($this->isInstanceOf($formatter, FormatterInterface::class)) {
            $formatter->formatRecords($records, $record);
        }

        $this->write($record);

        return $this->bubble;
    }
1048116
protected function formatRecordsList(array $records)
    {
        return collect($records)->mapWithKeys(function ($attributes, $id) {
            if (!is_array($attributes)) {
                list($id, $attributes) = [$attributes, []];
            }

            return [$id => $attributes];
        })->all();
    }
1117477
public void setRecords(java.util.Collection<Record> records) {
        if (records == null) {
            this.records = null;
            return;
        }

        this.records = new java.util.ArrayList<Record>(records);
    }
915456
def sort
      self.records.sort! do |x,y|
        comp = x[:request][:symbolized_path] <=> y[:request][:symbolized_path]
        comp.zero? ? (x[:title] <=> y[:title]) : comp
      end
    end
926310
def preceded_by(former)
      matches = SearchAtom.new
      latter = ActiveSupport::OrderedHash.new
      former.record_ids.each do |rid|
        latter[rid] = @records[rid] if @records[rid]
      end
      # Iterate over each record in latter.
      latter.each do |record_id,pos|

        # Iterate over each position.
        pos.each do |p|
          # Check if previous position is in former.
          if former.include_position?(record_id,p-1)
            matches.add_record(record_id) unless matches.include_record?(record_id)
            matches.add_position(record_id,p)
          end
        end

      end
      matches
    end
1219538
def limit_records(records)
      offset = self.offset
      limit  = self.limit
      size   = records.size

      if offset > size - 1
        []
      elsif (limit && limit != size) || offset > 0
        records[offset, limit || size] || []
      else
        records.dup
      end
    end
399703
def _rows_sort(self, rows):
        
        return sorted(rows, key=lambda row: (row[self._key_start_date], row[self._key_end_date]))
273258
private function getRecordsByHandle(array $records): array
    {
        $recordsByHandle = [];
        foreach ($records as $record) {
            $modelClass = get_class($record);
            $converter = Craft::$app->controller->module->getConverter($modelClass);
            $index = $converter->getRecordIndex($record);
            $recordsByHandle[$index] = $record;
        }

        return $recordsByHandle;
    }
382058
def custom_sort(enumerable)
      sorted_array = enumerable.sort_by do |key, _|
        key.sub(/^the\s*/i, '').downcase
      end

      # sort_by() returns an array when called on hashes.
      if enumerable.kind_of?(Hash)
        # Rebuild the hash.
        sorted_hash = {}
        sorted_array.each { |item| sorted_hash[item[0]] = item[1] }
        sorted_hash
      else
        sorted_array
      end
    end
373563
def sort(self, *, key: Optional[Callable[[Any], Any]] = None, reverse: bool = False) -> None:
        
        return list.sort(self, key=self._sort_key(key), reverse=reverse)
1207654
def query_sort(query, options)
      query.order(options[:order]) if options[:order]
      query.order(options[:desc_order], :desc) if options[:desc_order]
      query
    end