Simplified stable sort implementation from Lo-Dash (http://lodash.com/)
774759
function compareAscending(a, b) {
  var ai = a.idx,
      bi = b.idx;

  a = a.criteria;
  b = b.criteria;

  // ensure a stable sort in V8 and other engines
  // http://code.google.com/p/v8/issues/detail?id=90
  if (a !== b) {
    if (a > b || typeof a === 'undefined') {
      return 1;
    }
    /*istanbul ignore next*/
    if (a < b || typeof b === 'undefined') {
      return -1;
    }
  }

  /*istanbul ignore next*/
  return ai < bi ? -1 : 1;
}
1283254
function sortPosts (posts) {
  return Object.keys(posts).map(function (post) { return posts[post]; })
    .sort(function (a,b) {
      if ( a.date < b.date ) return 1;
      if ( a.date > b.date ) return -1;
      return 0;
    });
}
997282
function sortMessages(messages) {
  var fileArray = {
    error: [],
    warning: []
  };

  messages.forEach(function (message) {
    if (message.severity === 1) {
      fileArray.warning.push(message);
    } else {
      fileArray.error.push(message);
    }
  });

  return lodash.concat(fileArray.error, fileArray.warning);
}
543100
function StablePriorityQueue(comparator) {
    this.array = [];
    this.size = 0;
    this.runningcounter = 0;
    this.compare = comparator || defaultcomparator;
    this.stable_compare = function(a, b) {
      var cmp = this.compare(a.value,b.value);
      return (cmp < 0) || ( (cmp == 0) && (a.counter < b.counter) );
    }
}
1102721
function sortedHashKeys(obj, desc) {
		var keys = [];

		for (var key in obj)
			keys.push(key);

		return sort.call(keys, function(a,b) {
			return desc ? obj[b] - obj[a] : obj[a] - obj[b];
		});
	}
678437
def nargsort(items, kind='quicksort', ascending=True, na_position='last'):
    

    # specially handle Categorical
    if is_categorical_dtype(items):
        if na_position not in {'first', 'last'}:
            raise ValueError('invalid na_position: {!r}'.format(na_position))

        mask = isna(items)
        cnt_null = mask.sum()
        sorted_idx = items.argsort(ascending=ascending, kind=kind)
        if ascending and na_position == 'last':
            # NaN is coded as -1 and is listed in front after sorting
            sorted_idx = np.roll(sorted_idx, -cnt_null)
        elif not ascending and na_position == 'first':
            # NaN is coded as -1 and is listed in the end after sorting
            sorted_idx = np.roll(sorted_idx, cnt_null)
        return sorted_idx

    with warnings.catch_warnings():
        # https://github.com/pandas-dev/pandas/issues/25439
        # can be removed once ExtensionArrays are properly handled by nargsort
        warnings.filterwarnings(
            "ignore", category=FutureWarning,
            message="Converting timezone-aware DatetimeArray to")
        items = np.asanyarray(items)
    idx = np.arange(len(items))
    mask = isna(items)
    non_nans = items[~mask]
    non_nan_idx = idx[~mask]
    nan_idx = np.nonzero(mask)[0]
    if not ascending:
        non_nans = non_nans[::-1]
        non_nan_idx = non_nan_idx[::-1]
    indexer = non_nan_idx[non_nans.argsort(kind=kind)]
    if not ascending:
        indexer = indexer[::-1]
    # Finally, place the NaNs at the end or the beginning according to
    # na_position
    if na_position == 'last':
        indexer = np.concatenate([indexer, nan_idx])
    elif na_position == 'first':
        indexer = np.concatenate([nan_idx, indexer])
    else:
        raise ValueError('invalid na_position: {!r}'.format(na_position))
    return indexer
981160
function getHolders(array) {
      var index = -1,
          length = array.length,
          result = [];

      while (++index < length) {
        if (array[index] === lodash) {
          result.push(index);
        }
      }
      return result;
    }
218316
function jsonCompare(arg, options) {
    var sortOrder;
    if (typeof arg === 'string') {
        sortOrder = new SortOrder_1.SortOrder();
        sortOrder.fromJSON([arg]);
    }
    else if (_.isArray(arg)) {
        sortOrder = new SortOrder_1.SortOrder();
        sortOrder.fromJSON(arg);
    }
    else {
        sortOrder = arg;
    }
    var comparator = new SortOrderComparator(sortOrder, options);
    return (_.bind(comparator.compare, comparator));
}
889308
function (oList) {
					/* Sorting since records */
					let aKeys = Object.keys(oList),
						oSorted = {};

					aKeys.sort((a, b) => {
						let aA = a.split("."),
							aB = b.split(".");

						if (a === "noVersion") {
							return 1; /* No version always at end of list */
						}

						if (b === "noVersion") {
							return -1; /* No version always at end of list */
						}

						// Normalize old versions 1.4 to 1.04 for proper sorting
						a = [aA[0], ('0' + aA[1]).slice(-2)].join("");
						b = [aB[0], ('0' + aB[1]).slice(-2)].join("");

						// Sort descending
						return parseInt(b, 10) - parseInt(a, 10);
					});

					aKeys.forEach((sKey) => {
						oSorted[sKey] = oList[sKey];
					});

					return oSorted;
				}
224080
function sortArrayByIndex(array) {

  let ii = 0;
  let length = array.length;

  let output = [];

  for (; ii < length; ++ii) {
    output[array[ii].index] = array[ii];
    delete array[ii].index;
  };

  return (output);

}
389728
function sort(array &$var,$col,$order=SORT_ASC) {
		uasort(
			$var,
			function($val1,$val2) use($col,$order) {
				list($v1,$v2)=[$val1[$col],$val2[$col]];
				$out=is_numeric($v1) && is_numeric($v2)?
					Base::instance()->sign($v1-$v2):strcmp($v1,$v2);
				if ($order==SORT_DESC)
					$out=-$out;
				return $out;
			}
		);
		$var=array_values($var);
	}
500206
function sortedKeys(dictionary) {
  let keys = [];
  for (let key in dictionary) {
    keys.push(key);
  }
  return keys.sort();
}
1240912
def sort_dict(self, data, key):
    ''''''
    return sorted(data, key=itemgetter(key)) if data else []
81844
function arraySortByKey(data, key, reverse) {
    data.sort((a, b) => {
        const aw = a[key] !== undefined ? (
            typeof a[key] === 'function' ?
            parseInt(a[key](), 10) :
            parseInt(a[key], 10)
        ) : 0;
        const bw = b[key] !== undefined ? (
            typeof b[key] === 'function' ?
            parseInt(b[key](), 10) :
            parseInt(b[key], 10)
        ) : 0;

        if (aw === bw) {
            return 0;
        }

        return reverse !== true && aw < bw ? -1 : 1;
    });
}
102031
function sortCompare(left, right) {
        var hasj = $hasOwn(left, 0),
            hask = $hasOwn(right, 0),
            typex,
            typey,
            val;

        if (!hasj && !hask) {
            val = +0;
        } else if (!hasj) {
            val = 1;
        } else if (!hask) {
            val = -1;
        } else {
            typex = typeof left[0];
            typey = typeof right[0];
            if (typex === 'undefined' && typey === 'undefined') {
                val = +0;
            } else if (typex === 'undefined') {
                val = 1;
            } else if (typey === 'undefined') {
                val = -1;
            }
        }

        return val;
    }
155406
function lpush(key /*value-1, value-N, req*/) {
  var val = this.getKey(key, req)
    , args = slice.call(arguments, 1)
    , req;
  if(typeof args[args.length - 1] === 'object') {
    req = args.pop();
  }
  if(val === undefined) {
    val = new List();
    this.setKey(key, val, undefined, undefined, undefined, req);
  }
  return val.lpush(args);
}
754994
private static function stable_uasort(array &$array, $value_compare_func)
    {
        $index = 0;
        foreach ($array as &$item) {
            $item = array($index++, $item);
        }
        $result = uasort($array, function ($a, $b) use ($value_compare_func) {
            $result = call_user_func($value_compare_func, $a[1], $b[1]);
            return $result == 0 ? $a[0] - $b[0] : $result;
        });
        foreach ($array as &$item) {
            $item = $item[1];
        }
        return $result;
    }