Fixing bug in sorting algorithm. Adding the test case that was uncovering the bug