排序结果在php数组对象中

I am doing a ticket booking website, which fetches xml results via a SOAP request in PHP. The results are then returned in the form of PHP object array. And then I display those results using PHP. In one request there are over 300 results returned. So I need to build a show by price : low to high or high to low options for the end user. I have very little experience with PHP array objects, can any one please suggest the options that I can look into for this kind of sorting?

I was thinking of storing all the results to database table then sort then using SELECT query but since there would be many searches each day and each search resulting in at-least 300 entries would make the database very bulky very soon. Is there a way to store searches temporarily inside a database?

Thank you for taking your time in reading this. I will be happy to provide any further explanation if question above is not clear to anyone.

Here is an example of my data:

Array ( 
  [0] => stdClass Object ( 
    [Id] => HS 
    [Code] => CAUMJM 
    [Status] => InstantConfirmation 
    [Price] => 87 
    [Tax] => 0 
    [SalePrice] => 0 
    [currency] => USD 
    [Type] => Guest Only 
    [guests] => Array ( 
      [0] => stdClass Object ( 
        [Category] => Standard for 1 guest 
        [number] => Array ( [0] => stdClass Object ( [Type] => A[age] => 30 ) ) 
        [totalRate] => 87 
        [ratesPerHour] => Array ( [0] => stdClass Object ( [date] => 2014-08-20 [amount] => 87 ) ) 
      ) 
    ) 
  )
)

Try using usort. PHP Documentation

Supply the php array you want to sort and an anonymous function which will compare two of any of the array items and determine which item should be first in the list.

Unless I'm wrong it seems like you are getting the soap from a 3rd party service, in which case you wouldn't be able to query the results from a database. Instead of creating your own local database cache, you could store the results of the usort function in an in-memory storage like apc or memcached. Then the computation-heavy usort would only have to run once per query. This would significantly speed up the request time for sorted results.

The caching suggestions I made are a little off topic and not necessary to get the results you want. Look into them if you're interested, but I'll try and get you where you need to be first.

As far as your usort implementation goes, try something like this:

    $lowToHigh = function($a, $b) {
        return  $a->SalePrice < $b->SalePrice ? 1 : -1;
    };

    $highToLow = function($a, $b) {
        return  $a->SalePrice < $b->SalePrice ? -1 : 1;
    };

    // Sort results highest to lowest
    usort($results, $highToLow);
    // Sort results lowest to highest
    usort($results, $lowToHigh);

sql order by is better option. php arrays are expensive on bigger arrays

for arrays sorting in php look these methods

http://php.net/manual/en/array.sorting.php