Skip to content

Instantly share code, notes, and snippets.

@mithra62
Created November 13, 2013 03:39
Show Gist options
  • Save mithra62/7443308 to your computer and use it in GitHub Desktop.
Save mithra62/7443308 to your computer and use it in GitHub Desktop.
<?php
$sorted = array();
foreach($array AS $key => $value)
{
$sort_key = (empty($sorted[$value['amount']]) ? $value['amount'] : $value['amount']+1);
$sorted[$sort_key] = $value;
}
krsort($sorted);
@mithra62
Copy link
Author

<?php

$sorted = array();
foreach($array AS $key => $value)
{
    $sort_key = (empty($sorted[$value->amount]) ? $value->amount : $value->amount+1);
    $sorted[$sort_key] = $value;
}

krsort($sorted);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment