Sort the rows, as appropriate for the section.

        :param rows: List of tuples (all same length, same values in each position)
        :param section: Name of section, should match const in Differ class
        :return: None; rows are sorted in-place
355943
def sort_rows(self, rows, section):
        
        #print("@@ SORT ROWS:\n{}".format(rows))
        # Section-specific determination of sort key
        if section.lower() == Differ.CHANGED.lower():
            sort_key = Differ.CHANGED_DELTA
        else:
            sort_key = None
        if sort_key is not None:
            rows.sort(key=itemgetter(sort_key))
1173622
def extract_rows(data, *rows):
    
    try:
        # for python 2.2
        # return [data[r] for r in rows]
        out = []
        for r in rows:
            out.append(data[r])
        return out
    except IndexError:
        raise IndexError("data=%s rows=%s" % (data, rows))
    return out
1262262
def filter_sections(sections):
    
    if not sections:
        return None
    jobs = []
    matchers = python_version_matchers()
    for name, options in sections:
        target_version = options.pop('python', None)
        if target_version in matchers:
            jobs.append((name, options))
    return jobs
932949
@Override
    public void orderRows(final OrderBy ob) {
        if (ob != null) {
            ob.setMetaData(getMetaData());
            ob.setParser(parser);
            Collections.sort(rows, ob);
            goTop();
        }
    }
748554
def _filter_rows(self, rows, visible_columns=None):
        """"""
        if visible_columns is None:
            visible_columns = self.visible_columns
        filtered_row = []
        for idx, name in enumerate(self.columns.keys()):
            if name in self.visible_columns:
                filtered_row.append(rows[idx])
        return filtered_row
577076
def add_rows(self, rows, header=True):
        

        # nb: don't use 'iter' on by-dimensional arrays, to get a
        #     usable code for python 2.1
        if header:
            if hasattr(rows, '__iter__') and hasattr(rows, 'next'):
                self.header(rows.next())
            else:
                self.header(rows[0])
                rows = rows[1:]
        for row in rows:
            self.add_row(row)
        return self
523093
def add_row(self, data: list=None):
        
        # validation
        if self.headers and data:
            if len(self.headers) != len(data):
                raise ValueError

        offset = 0 if not self.headers else 1
        row = list()

        if data:
            for i, element in enumerate(data):
                contents = '' if element is None else str(element)
                entry = ttk.Entry(self)
                entry.insert(0, contents)
                entry.grid(row=len(self._rows) + offset,
                           column=i,
                           sticky='E,W')
                row.append(entry)
        else:
            for i in range(self.num_of_columns):
                entry = ttk.Entry(self)
                entry.grid(row=len(self._rows) + offset,
                           column=i,
                           sticky='E,W')
                row.append(entry)

        self._rows.append(row)

        # clear all bindings
        for row in self._rows:
            for widget in row:
                widget.unbind('<Tab>')

        def add(e):
            self.add_row()

        last_entry = self._rows[-1][-1]
        last_entry.bind('<Tab>', add)

        e = self._rows[-1][0]
        e.focus_set()

        self._redraw()
982268
function sortSegmentRow(segments) {
		var sortedSegments = [];

		// build the subrow array
		var subrows = buildSegmentSubrows(segments);

		// flatten it
		for (var i=0; i<subrows.length; i++) {
			sortedSegments.push.apply(sortedSegments, subrows[i]); // append an array to an array
		}

		return sortedSegments;
	}
637941
def section(self, resources):
        

        section = [p for p in self.parents(resources) if p.rtype == 'section']
        if section:
            return section[0]
        return None
454409
def previous(self, rows: List[Row]) -> List[Row]:
        
        if not rows:
            return []
        input_row_index = self._get_row_index(rows[0])
        if input_row_index > 0:
            return [self.table_data[input_row_index - 1]]
        return []
1334721
def sort(self, section: int, order=None):
        """"""
        attr = self.header[section]
        old_i, old_sort = self.sort_state
        self.beginResetModel()
        if section == old_i:
            self.collection.sort(attr, not old_sort)
            self.sort_state = (section, not old_sort)
        else:
            self.collection.sort(attr, True)
            self.sort_state = (section, True)
        self.endResetModel()
1193315
def _rows_differ(row, _row):
    '''
    
    '''
    row_copy = copy.deepcopy(row)
    _row_copy = copy.deepcopy(_row)
    # Strip id from all panels in both rows, since they are always generated.
    for panel in row_copy['panels']:
        if 'id' in panel:
            del panel['id']
    for _panel in _row_copy['panels']:
        if 'id' in _panel:
            del _panel['id']
    diff = DictDiffer(row_copy, _row_copy)
    return diff.changed() or diff.added() or diff.removed()
1362906
def selection_range_at_line(self, row):
        
        if self.selection:
            row_start = self.translate_row_col_to_index(row, 0)
            row_end = self.translate_row_col_to_index(row, max(0, len(self.lines[row]) - 1))

            from_, to = sorted([self.cursor_position, self.selection.original_cursor_position])

            # Take the intersection of the current line and the selection.
            intersection_start = max(row_start, from_)
            intersection_end = min(row_end, to)

            if intersection_start <= intersection_end:
                if self.selection.type == SelectionType.LINES:
                    intersection_start = row_start
                    intersection_end = row_end
                elif self.selection.type == SelectionType.BLOCK:
                    _, col1 = self.translate_index_to_position(from_)
                    _, col2 = self.translate_index_to_position(to)
                    col1, col2 = sorted([col1, col2])
                    intersection_start = self.translate_row_col_to_index(row, col1)
                    intersection_end = self.translate_row_col_to_index(row, col2)

                _, from_column = self.translate_index_to_position(intersection_start)
                _, to_column = self.translate_index_to_position(intersection_end)

                return from_column, to_column
272387
def sort_sections(self, order):
        

        order_lc = [e.lower() for e in order]

        sections = OrderedDict( (k,self.sections[k]) for k in order_lc if k in self.sections)

        sections.update( (k,self.sections[k]) for k in self.sections.keys() if k not in order_lc)

        assert len(self.sections) == len(sections)

        self.sections = sections
1063522
def rows(collection = nil, &block)
      return @rows if collection.nil?

      unless collection.respond_to?(:each)
        raise ArgumentError, 'csv.rows only accepts Enumerable object (that respond to #each). Use csv.row for a single object.'
      end

      collection.each do |element|
        row(element, &block)
      end

      @rows
    end
1365681
def iter_rows(self, start=None, end=None):
        """"""
        start = start or 0
        end = end or self.nrows
        for i in range(start, end):
            yield self.iloc[i, :]
267430
def order_by_header(table, headers):
    ''''''
    ordered_table = []
    for row in table:
        # Tricky list comprehension got tricky when needing special handling
        # Lets do this the simplest way we can:
        row = {k:v for k,v in row.items() if k in headers}
        for h in headers:
            if h not in row:
                row[h] = ''
        ordered_row = OrderedDict(sorted(row.items(),
                                         key=lambda x:headers.index(x[0])))
        ordered_table.append(ordered_row)
    return ordered_table