Reference Number Sorting

Hi @lubos
I get the same problem with the payments and receipts