dynamic sorted jagged array data structure in Javascript programming language