Suggestions for Improving Test Case Sorting Algorithm

I used a treemap to sort and loop through my test cases, but I only managed to get two of them correct. I’m wondering if there is a better algorithm or approach that others have used successfully. It’s possible that using a treemap was not the best choice for this problem, as many problems can be solved with just an array as a data structure.
Thank You….