Fixed some bugs in the cache sorting, and reversed the sort order.