Added A LOT of changes to the code in order to get the ranks and sort by
it. getneighbors may be wrong, the numpy manipulation may be wrong and
the passing of the parameter to the table may be wrong too.