added sorting to the js example