3v4l.org

run code in 300+ PHP versions simultaneously
<?php $js = '{ "BHS": { "text": "Beacon Hill School", "optgroup": "Kowloon" }, "HSK": { "text": "ESF International Kindergarten (Hillside)", "optgroup": "Hong Kong Island" }, "KJS": { "text": "Kowloon Junior School", "optgroup": "Kowloon" } }'; $json = json_decode($js); function sortByText($a, $b) { return ord($a['text'][0]) - ord($b['text'][0]); } usort($json, 'sortByText'); var_dump($json);

preferences:
49.39 ms | 402 KiB | 5 Q