Sort
A collection of array sorting transforms and functions
Install / Use
/learn @graze/SortREADME
Sort
<img src="http://media2.giphy.com/media/fAaAo6SyjVJf2/200.gif" alt="sort" align="right" height=200/>This library provides a few useful functions used for sorting large arrays or
sorting where comparing array values is expensive to perform. The intention is
to provide these functions while remaining interoperable with PHP's built-in
usort functions where possible.
It can be installed in whichever way you prefer, but we recommend Composer.
{
"require": {
"graze/sort": "*"
}
}
Documentation
<?php
$unsorted = [
(object) ['foo' => 1, 'bar' => 3],
(object) ['foo' => 3, 'bar' => 2],
(object) ['foo' => 2, 'bar' => 1],
(object) ['foo' => 2, 'bar' => 2],
(object) ['foo' => 3, 'bar' => 3],
(object) ['foo' => 1, 'bar' => 1],
(object) ['foo' => 2, 'bar' => 3],
(object) ['foo' => 3, 'bar' => 1],
(object) ['foo' => 1, 'bar' => 2]
];
$foo = function ($v) { return $v->foo; };
$bar = function ($v) { return $v->bar; };
// Using comparison sorting
$sorted = \Graze\Sort\comparison($unsorted, [$foo, $bar]);
// Using schwartzian sorting
$sorted = \Graze\Sort\schwartzian($unsorted, [$foo, $bar]);
// Using comparison sorting with usort
$sorted = $unsorted;
usort($sorted, \Graze\Sort\comparison_fn($unsorted, [$foo, $bar]));
<!-- Links -->Related Skills
node-connect
346.4kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
107.2kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
346.4kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
346.4kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。

