Sort scanned commands