Non-recursive merge sort implementation in JavaScript (WORK IN PROGRESS VERY BROKEN)