Well, at a glance it looks like $j will remain zero forever...
In reply to Re^3: Sort over remaining part of array by hdb in thread Sort over remaining part of array by monkini