Completed full counting sort with twist.