Sort the rest API routes so that they are in a stable order.

Addresses issue #494.
Using the "cmp" argument to sort might be cleaner than creating "sortkeys" here and then repacking it at the return. Just a thought.