sorts a sortable in human order (0 < 20 < 100)
194967
def natural_sorted(l):
    
    ll = copy(l)
    ll.sort(key=_natural_keys)
    return ll
751218
function sort(children, sortOrder) {
    if (typeof sortOrder === 'function') {
        return children.sort(sortOrder);
    }
    else {
        var isAsc = sortOrder === 'asc';
        return children.sort(function (a, b) {
            var diff = (a.getValue() - b.getValue()) * (isAsc ? 1 : -1);
            return diff === 0
                ? (a.dataIndex - b.dataIndex) * (isAsc ? -1 : 1)
                : diff;
        });
    }
}
658546
public static <T, L extends List<T>> L sortThis(L list, Comparator<? super T> comparator)
    {
        if (list instanceof MutableList)
        {
            ((MutableList<T>) list).sortThis(comparator);
        }
        else if (list instanceof ArrayList)
        {
            ArrayListIterate.sortThis((ArrayList<T>) list, comparator);
        }
        else
        {
            if (list.size() > 1)
            {
                Collections.sort(list, comparator);
            }
        }
        return list;
    }
534936
def sort(input, property = nil, nils = "first")
      raise ArgumentError, "Cannot sort a null object." if input.nil?

      if property.nil?
        input.sort
      else
        if nils == "first"
          order = - 1
        elsif nils == "last"
          order = + 1
        else
          raise ArgumentError, "Invalid nils order: " \
            "'#{nils}' is not a valid nils order. It must be 'first' or 'last'."
        end

        sort_input(input, property, order)
      end
    end
1319936
def _order_as_range(order):
    """"""
    order = order.split('-')
    order = [int(o) for o in order]
    if len(order) > 1:
        order = range(order[0], (order[-1] + 1))
    return order
476413
def csort(objs, key):
    """"""
    idxs = dict((obj, i) for (i, obj) in enumerate(objs))
    return sorted(objs, key=lambda obj: (key(obj), idxs[obj]))
1177682
public static void sort(int[] arr) {
        int n = arr.length;
        for (int i = n / 2 - 1; i >= 0; i--)
            SortUtils.siftDown(arr, i, n - 1);

        for (int i = n - 1; i > 0; i--) {
            SortUtils.swap(arr, 0, i);
            SortUtils.siftDown(arr, 0, i - 1);
        }
    }
313388
def sort_ascending(self, key):
        """"""

        row, col, tab = key

        scells = self.grid.code_array[:, col, tab]

        def sorter(i):
            sorted_ele = scells[i]
            return sorted_ele is None, sorted_ele

        sorted_row_idxs = sorted(xrange(len(scells)), key=sorter)

        self.replace_cells(key, sorted_row_idxs)

        self.grid.ForceRefresh()
672980
function sortFn(a, b) {
    var apct = getWeightedPercent(a);
    var bpct = getWeightedPercent(b);
    var diff = apct - bpct;

    if (diff === 0) {
      return ascending(a.id(), b.id()); // make sure sort doesn't have don't-care comparisons
    } else {
      return diff;
    }
  }
1241513
private static void sort(int[] a, int n) {
        int inc = 1;
        do {
            inc *= 3;
            inc++;
        } while (inc <= n);

        do {
            inc /= 3;
            for (int i = inc; i < n; i++) {
                int v = a[i];
                int j = i;
                while (a[j - inc] < v) {
                    a[j] = a[j - inc];
                    j -= inc;
                    if (j < inc) {
                        break;
                    }
                }
                a[j] = v;
            }
        } while (inc > 1);
    }
469192
public function sort()
    {
        usort(
            $this->items,
            function ($a, $b) {
                if ($a[0] === $b[0]) {
                    return 0;
                }
                return $a[0] < $b[0] ? -1 : 1;
            }
        );
    }
1144760
def actual_sort(self):
        """"""
        if not self._actual_sort:

            # trigger evaluation of operation
            if self.operation in ['query', 'getmore']:
                self._actual_sort = self._find_pattern('orderby: ',
                                                        actual=True)

        return self._actual_sort
1028103
function(a, b) {
          let aVal = a[sortField];
          let bVal = b[sortField];
          return (!aVal && bVal) || (aVal < bVal) ? -1 : (aVal && !bVal) || (aVal > bVal) ? 1 : 0;
        }
1092697
def sort(self, column, order=Qt.AscendingOrder):
        """"""
        ascending = order == Qt.AscendingOrder
        self.model.sort(self.COLUMN_INDEX, order=ascending)
        return True
382565
def sortedbyAge(self):
		'''
		
		'''
		ageAll = numpy.zeros(self.length)
		for i in range(self.length):
			ageAll[i] = self.Ind[i].age
		ageSorted = ageAll.argsort()
		return ageSorted[::-1]
259863
def natural_sort(l, field=None):
    '''
    
    '''
    convert = lambda text: int(text) if text.isdigit() else text.lower()

    def alphanum_key(key):
        if field is not None:
            key = getattr(key, field)
        if not isinstance(key, str):
            key = str(key)
        return [convert(c) for c in re.split('([0-9]+)', key)]
    return sorted(l, key=alphanum_key)
1126624
final void normalizeRowOrder() {
    Collections.sort(rows, (a,b) -> Integer.compare(a.hashCode(), b.hashCode()));    
  }