How do I sort the output of listtransactions "*"? I am testing some new code, and need to sort the output of listtransactions. Ultimately I need to verify that there are no duplicate txids.

How do I output  ./bitcoind -datadir=1 listtransactions "*" to a logfile, or sort it directly in the terminal window?
You can run the listtransaction JSON output through this little python script (save it as jsonTOCSV.py). That will produce csv (comma separated value) output that Excel or Google Spreadsheets can import, both of which can sort by columns (if I recall correctly).

So:


  bitcoind listtransactions | jsonTOCSV.py > transactions.csv


#!/usr/bin/env python
#
# Reads an array of JSON objects and writes out CSV-format,
# with key names in first row.
# Columns will be union of all keys in the objects.
#

import csv
import json
import sys

json_string = sys.stdin.read()
json_array = json.loads(json_string)

columns = set()
for item in json_array:
  columns.update(set(item))

writer = csv.writer(sys.stdout)
writer.writerow(list(columns))
for item in json_array:
  row = []
  for c in columns:
    if c in item: row.append(str(item[c]))
    else: row.append('')
  writer.writerow(row)