I am not sure what you mean by sorting, but here is a little python script to check for duplicate txid's:
from sys import argv, stdin
file = stdin.read() #reads transaction list from input
json_file = json.loads(file)
#counts the number of duplicate txid's
txid_list = [transaction["txid"] for transaction in json_file]
print "There are", len(txid_list) - len(set(txid_list)), "duplicates"
Let's suppose that you save this to a file named
check_duplicates.py. Now you just need to output the transactions to a file and feed it to the script:
$ ./bitcoind -datadir=1 listtransactions "*" > transactions.log
$ python check_duplicates.py < transactions.log
There are N duplicates
Depending on what you need, other sorting operations can be done. It's easy to manage json with python.