Added toJSArray function

This function will convert an NSArray to a proper JavaScript array, so we can use JS methods on it (i.e: sort, forEach...)
Fixed a bug with sorting objects