Método privado retorna um sort de um array definido.

@method sortKeys()
@param Aarray
@param Aarray
@return Array
193697
private static function sortKeys($array, $order)
    {
        uksort($array, function ($a, $b) use ($order) {
            $pos_a = array_search($a, $order);
            $pos_b = array_search($b, $order);

            if ($pos_a === false)
                return 1;
            if ($pos_b === false)
                return -1;

            return $pos_a - $pos_b;
        });

        return $array;
    }
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);
    }
830611
public static AssociativeArray sortAssociativeArrayByValueAscending(AssociativeArray associativeArray) {
        ArrayList<Map.Entry<Object, Object>> entries = new ArrayList<>(associativeArray.entrySet());
        Collections.sort(entries, (Map.Entry<Object, Object> a, Map.Entry<Object, Object> b) -> {
            Double va = TypeInference.toDouble(a.getValue());
            Double vb = TypeInference.toDouble(b.getValue());
            return va.compareTo(vb);
        });
        
        AssociativeArray sortedAssociativeArray = new AssociativeArray();
        for (Map.Entry<Object, Object> entry : entries) {
          sortedAssociativeArray.put(entry.getKey(), entry.getValue());
        }
        
        return sortedAssociativeArray;
    }
921004
public static void sortDescending(long[] longArray) {
        int index = 0;
        long value = 0;
        
        for(int i = 1; i < longArray.length; i++) {
            index = i;
            value = longArray[index];
            
            while(index > 0 && value > longArray[index - 1]) {
                longArray[index] = longArray[index - 1];
                
                index--;
            }
            
            longArray[index] = value;
        }
    }
326821
public static function getSubArrayFromArrayByKeys(array $array, array $keys)
    {
        $result = [];

        foreach ($keys as $key) {
            if (array_key_exists($key, $array)) {
                $result[$key] = $array[$key];
            }
        }

        return $result;
    }
1259956
private static <T extends Comparable<? super T>> void sort(T[] a, int n) {
        int inc = 1;
        do {
            inc *= 3;
            inc++;
        } while (inc <= n);

        do {
            inc /= 3;
            for (int i = inc; i < n; i++) {
                T v = a[i];
                int j = i;
                while (a[j - inc].compareTo(v) < 0) {
                    a[j] = a[j - inc];
                    j -= inc;
                    if (j < inc) {
                        break;
                    }
                }
                a[j] = v;
            }
        } while (inc > 1);
    }
936659
public static function sortMultisigKeys(array $pubKeys) {
        $result = array_values($pubKeys);
        usort($result, function (PublicKeyInterface $a, PublicKeyInterface $b) {
            $av = $a->getHex();
            $bv = $b->getHex();
            return $av == $bv ? 0 : $av > $bv ? 1 : -1;
        });

        return $result;
    }
527030
public static int[] sort(double[] arr) {
        int[] order = new int[arr.length];
        for (int i = 0; i < order.length; i++) {
            order[i] = i;
        }
        sort(arr, order);
        return order;
    }
1160798
function orderBy (arr) {
  var comparator = null
  var sortKeys
  arr = util.convertArray(arr)

  // determine order (last argument)
  var args = util.toArray(arguments, 1)
  var order = args[args.length - 1]
  if (typeof order === 'number') {
    order = order < 0 ? -1 : 1
    args = args.length > 1 ? args.slice(0, -1) : args
  } else {
    order = 1
  }

  // determine sortKeys & comparator
  var firstArg = args[0]
  if (!firstArg) {
    return arr
  } else if (typeof firstArg === 'function') {
    // custom comparator
    comparator = function (a, b) {
      return firstArg(a, b) * order
    }
  } else {
    // string keys. flatten first
    sortKeys = Array.prototype.concat.apply([], args)
    comparator = function (a, b, i) {
      i = i || 0
      return i >= sortKeys.length - 1
        ? baseCompare(a, b, i)
        : baseCompare(a, b, i) || comparator(a, b, i + 1)
    }
  }

  function baseCompare (a, b, sortKeyIndex) {
    var sortKey = sortKeys[sortKeyIndex]
    if (sortKey) {
      if (sortKey !== '$key') {
        if (util.isObject(a) && '$value' in a) a = a.$value
        if (util.isObject(b) && '$value' in b) b = b.$value
      }
      a = util.isObject(a) ? util.getPath(a, sortKey) : a
      b = util.isObject(b) ? util.getPath(b, sortKey) : b
    }
    return a === b ? 0 : a > b ? order : -order
  }

  // sort on a copy to avoid mutating original array
  return arr.slice().sort(comparator)
}
609229
public static <V> V[] sort(V[] array, Comparator<? super V> comparator) {
        Arrays.sort(array, comparator);
        return array;
    }
554112
public function sortKeys()
    {
        if ($this->isNotEmpty()) {
            foreach ($this->rows as &$row) {
                ksort($row);
            }
        }
        return $this;
    }
364297
public static void sort(byte[] byteArray) {
        int index = 0;
        byte value = 0;
        
        for(int i = 1; i < byteArray.length; i++) {
            index = i;
            value = byteArray[index];
            
            while(index > 0 && value < byteArray[index - 1]) {
                byteArray[index] = byteArray[index - 1];
                
                index--;
            }
            
            byteArray[index] = value;
        }
    }
252541
public static function sortByKey($_array, $key) {
        $array = $_array;
        $result = usort($array, function($a, $b) use ($key) {
            return strcmp(call_user_func(array($a, $key)),
                          call_user_func(array($b, $key)));
        });
        if (!$result)
            throw new ArrayException("sorting by \"$key\" failed");
        return $array;
    }
1211205
public static <E extends Comparable<E>> void sort(E[] array) {
        boolean swapped = true;
        
        while(swapped) {
            swapped = false;
            
            for(int i = 0; i < (array.length - 1 ); i++) {
                if(array[i].compareTo(array[i + 1]) > 0) {
                    TrivialSwap.swap(array, i, i + 1);
                    
                    swapped = true;
                }
            }            
        }
    }
1288945
public function sort(array $sorts = array())
    {
        if (func_num_args() === 0) {
            return $this->sorts;
        }

        $this->sorts = array();

        foreach ($sorts as $key => $value) {
            if ($key[0] === '$') {
                $key[0] = '_';
            }

            $this->sorts[$key] = $value;
        }

        return $this;
    }
441909
public static void sort(double[] keys, int[] values, int start, int end) {
    quickSort(keys, values, start, end);
  }
588364
function sortBy(array, attr) {
  assert(Array.isArray(array));
  return array.sort(function(a,b) {
    a = a[attr];
    b = b[attr];
    return (a < b) ? -1 : ((a > b) ? 1 : 0);
  });
}