MCPcopy Index your code
hub / github.com/clips/pattern / sort

Method sort

pattern/db/__init__.py:2044–2053  ·  view source on GitHub ↗
(self, cmp=None, key=None, reverse=False, order=None)

Source from the content-addressed store, hash-verified

2042 return list(self).index(column)
2043
2044 def sort(self, cmp=None, key=None, reverse=False, order=None):
2045 # This makes most sense if the order in which columns should appear is supplied.
2046 o = order and order or _order(self, cmp, key, reverse)
2047 for i, row in enumerate(self._datasheet):
2048 # The main difficulty is modifying each row in-place,
2049 # since other variables might be referring to it.
2050 r=list(row); [row.__setitem__(i2, r[i1]) for i2, i1 in enumerate(o)]
2051 # Reorder the datasheet headers.
2052 if self._datasheet.fields is not None:
2053 self._datasheet.fields = [self._datasheet.fields[i] for i in o]
2054
2055 def swap(self, j1, j2):
2056 self[j1], self[j2] = self[j2], self[j1]

Callers

nothing calls this directly

Calls 1

__setitem__Method · 0.45

Tested by

no test coverage detected