title: How to sort LevelDB by value
body: <p>I'm using <a href="http://code.google.com/p/leveldb/" rel="nofollow">leveldb</a> to store records (key-value), where the key is a 64-bit hash and the value is a double. To make an analogy: think of the 64-bit hash is a unique ID of a customer and the double as an account balance (i.e. how much money they have in their account). I want to sort the database by account balance and list the customers with the highest account balance first. However, the database cannot fit into memory so I have to use some other method for sorting it in order to sort by account balance.</p>
  
  <p>I'm considering using <a href="http://stxxl.sourceforge.net/" rel="nofollow">STXXL</a>, but it requires that I make a copy of the database into a single flat file, then I can use STXXL to do an external sort (which would make a bunch of smaller files, sort them and then merge them back into another single flat file). Is there a better approach to sorting the data or should I go with the STXXL sort?</p>