You are here:  » Sort order in price comp table

Support Forum



Sort order in price comp table

Submitted by SimonK on Thu, 2011-03-10 16:41 in

Hi David

I'd like to display my price comp table in reverse, ie the highest price first. Presumably I need to change an ASC into a DESC somewhere, but for the life of me I can't see where!

Please can you let me know which file I need to modify.

Thanks
Simon

Submitted by support on Thu, 2011-03-10 16:51

Hi Simon,

It was indeed simply in the SQL until the latest distribution, but since voucher codes may now be considered on the product page sorting is done within the PHP code using usort() and the cmp() function beginning at line 49 of products.php

      function cmp($a, $b)
      {
        if ($a["price"] == $b["price"])
        {
            return 0;
        }
        return ($a["price"] < $b["price"]) ? -1 : 1;
      }

To reverse the sort order, REPLACE the above code with:

      function cmp($a, $b)
      {
        if ($a["price"] == $b["price"])
        {
            return 0;
        }
        return ($a["price"] > $b["price"]) ? -1 : 1;
      }

Cheers,
David.
--
PriceTapestry.com

Submitted by SimonK on Thu, 2011-03-10 17:38

Thanks David :-)