Sort the string question

Question link : https://hack.codingblocks.com/app/practice/6/p/1121

My code : https://ide.codingblocks.com/s/162445

Whats wrong in the code? All testcases are failed. But according to me, code is right.

All three testcases showing run-error

key no can range from 1 to 50. your code works for just when there are 2 keys in each string

can you debug this code please

Ritik , you have probably replied on the wrong post.