changed logs to print sortedMoves, fixed sorting by changing index to i