refine js for sorting fixes #31