/*
sort(input, property = nil)

Sort elements of the array provide optional property with
which to sort an array of hashes or drops
3157
@Override
    public Object apply(Object value, Object... params) {

        if (value == null) {
            return "";
        }

        if(!super.isArray(value)) {
            throw new RuntimeException("cannot sort: " + value);
        }

        Object[] array = super.asArray(value);
        String property = params.length == 0 ? null : super.asString(params[0]);

        List<Comparable> list = asComparableList(array, property);

        Collections.sort(list);

        return property == null ?
                list.toArray(new Comparable[list.size()]) :
                list.toArray(new SortableMap[list.size()]);
    }
1336035
function() {

      var x, sortable, els;

      els = document.querySelectorAll('[hashedit-sortable]');

      // walk through sortable clases
      for (x = 0; x < els.length; x += 1) {

        if(els[x].firstElementChild === null){
          els[x].setAttribute('hashedit-empty', 'true');
        }
        else {
          els[x].removeAttribute('hashedit-empty');
        }

      }

    }
867235
function sort(array, compare) {
  if (array.length <= 1) {
    return array;
  }

  var i;
  var middle = Math.floor(array.length / 2);
  var left = new Array(middle);
  var right = new Array(array.length - middle);

  for (i = 0; i < left.length; i++) {
    left[i] = array[i];
  }
  for (i = 0; i < right.length; i++) {
    right[i] = array[i + left.length];
  }

  return merge(sort(left, compare), sort(right, compare), compare);
}
1020721
function hashObject (obj) {
  if (!isObject(obj)) return null;
  return shortHash(JSON.stringify(sortKeys(obj, { deep: true })));
}
414389
function sortTags(data) {
  const toBuffer = (str) => {
    if (Buffer.from && Buffer.from !== Uint8Array.from) {
      return Buffer.from(str);
    }
    return new Buffer(str); // eslint-disable-line
  };
  const keys = _.map(_.keys(data), toBuffer).sort(Buffer.compare);
  const result = {};
  _.forEach(keys, (key) => {
    const k = key.toString();
    result[k] = data[k];
  });
  return result;
}
11713
def sort=(sort)
      validator = EnumAttributeValidator.new('String', ["COUNT", "INDEX"])
      unless validator.valid?(sort)
        fail ArgumentError, "invalid value for 'sort', must be one of #{validator.allowable_values}."
      end
      @sort = sort
    end
34459
function sortUnique(a) {
  var n=a.length;
  if (n<=1) return a;
  //do a shell sort
  var k=1,hi=n/3|0,i,j,tmp;
  while (k < hi) k=k*3+1;
  while (k > 0) {
    for (i=k;i<n;i++) {
      for (j=i;j>=k && a[j]<a[j-k];j-=k) {
        tmp=a[j]; a[j]=a[j-k]; a[j-k]=tmp;
      }
    }
    k=k/3|0;
  }

  var last=a[0],x;
  for (i=1,j=1;i<n;i++) {
    x=a[i];
    if (x===last) continue;
    last=a[j++]=a[i];
  }
  a.length=j;
  return a.length===j?a:copyArray(a,j); //Typed Array length property only has a getter
}
561340
def uniq(input, property = nil)
      ary = InputIterator.new(input)

      if property.nil?
        ary.uniq
      elsif ary.empty? # The next two cases assume a non-empty array.
        []
      elsif ary.first.respond_to?(:[])
        begin
          ary.uniq { |a| a[property] }
        rescue TypeError
          raise_property_error(property)
        end
      end
    end
460510
function(array) {
    let sorted = array.sort((a, b) => {
      return a.id - b.id;
    });
    let i = sorted.length - 1;
    while (i--)
      if (sorted[i + 1].id === sorted[i].id)
        sorted.splice(i,1);

    return sorted;
  }
1183161
function sortObject(obj) {
  assert.ok(_.isObject(obj), 'Parameter should be an object! - ' + util.inspect(obj));
  assert.ok(!_.isArray(obj), 'Parameter should be an object, got array: ' + util.inspect(obj));

  var sortedKeys = _.keys(obj).sort();
  var sortedObjs = [];

  _.each(sortedKeys, function(key) {
    var val = {};
    val[key] = obj[key];
    sortedObjs.push(val);
  });

  return sortedObjs;
}
1002564
def sortProperties(self, properties):  # modified to sort objects using their global rank
        """"""
        # Sort object lists
        for prop, objects in properties.items():
            objects.sort(key=self._globalSortKey)

        # Make sorted list of properties
        return sorted(properties, key=lambda p: self.predicate_rank[p])
1058940
public static <T> List<T> sortByProperty(Collection<T> collection, String property) {
		return sort(collection, new PropertyComparator<>(property));
	}
1185670
function hash(object) {
    if (object === undefined || isScalar(object)) {
        return '' + object;
    }

    if (object.hash) {
        return object.hash();
    }

    //Default implementation
    var hashes = [],
        value, key, hashKey, hashValue;

    for (key in object) {
        if (object.hasOwnProperty(key)) {
            value = object[key];
            hashKey = String(key);
            hashValue = hash(value);
            hashValue = (hashKey > hashValue) ? hashValue + hashKey : hashKey + hashValue;
            hashes.push(hashValue);
        }
    }

    return hashes.sort().join('');
}
1027612
function orderBy(expression) {

        //Check arguments
        if (!expression)
            throw new Error("Expression is invalid");
		
		//Define sort action estracting values from objects
		var sortAction = function(a, b){
		
			//Get value for "a" and "b" element
			var aValue = expression(a);
			var bValue = expression(b);
		
			//Check if one element is greater then the second one
			if(aValue < bValue) return -1;
			if(aValue > bValue) return 1;
			return 0;
		};
		
		//Copy array in order to avoid modifications on original
		var outData = [];
		for(var i = 0; i < this.items.length; i++){
			outData.push(this.items[i]);
		}

        //Define output array
        var sortedData = outData.sort(sortAction);
        
        //Return for chaining
        return new jslinq(sortedData);
    }
73818
function (locationsarray) {
			this.writeDebug('sortNumerically',arguments);
			var property = (
				this.settings.sortBy !== null &&
				this.settings.sortBy.hasOwnProperty('prop') &&
				typeof this.settings.sortBy.prop !== 'undefined'
			) ?  this.settings.sortBy.prop : 'distance';

			if (this.settings.sortBy !== null && this.settings.sortBy.hasOwnProperty('order') && this.settings.sortBy.order.toString() === 'desc') {
				locationsarray.sort(function (a, b) {
					return ((b[property] < a[property]) ? -1 : ((b[property] > a[property]) ? 1 : 0));
				});
			} else {
				locationsarray.sort(function (a, b) {
					return ((a[property] < b[property]) ? -1 : ((a[property] > b[property]) ? 1 : 0));
				});
			}
		}
693203
function sortIndexes(indexes, sort) {
	function compare(a, b) {
		return a > b ? -1 : (b > a ? 1 : 0);
	}

	// format: [{ name: 'colName', direction: 'asc' }, { name: 'colName2', direction: 'desc' }]
	// direction is 'asc' by default

	indexes.sort(function (a, b) {
		var result = 0;

		for (var i = 0; i < sort.length && result === 0; i++) {
			var prop = sort[i].name;
			var factor = sort[i].direction === 'desc' ? -1 : 1;

			result = factor * compare(a[prop], b[prop]);
		}

		return result;
	});
}
985408
public static <E extends Comparable<E>> void sort(E[] array) {
        int index = 0;
        E value = null;
        
        for(int i = 1; i < array.length; i++) {
            index = i;
            value = array[index];

            while(index > 0 && value.compareTo(array[index - 1]) < 0) {
                array[index] = array[index - 1];
                
                index--;
            }
            
            array[index] = value;
        }
    }