First steps toward improving sorting at SQLite level (caveman solution)