Fixed sorting, added JSON call for top ten

Fixed example code sorting and insert, added a JSON example to get the
top ten list.