Fix random sort functionality.