Java Sort Object Array Javascript Iteration