JavaScript's .sort() method works in simulator but not on iOS device
See original GitHub issueI am trying to sort a list of events by date using JavaScript’s built in .sort() method. I am using a ListView to display the data. In dataSource.cloneWithRows()
I pass in a function that is supposed to return a sorted array of events. For some reason this works fine in the simulator but doesn’t work on my iOS device. Any help is appreciated!
Issue Analytics
- State:
- Created 7 years ago
- Comments:10 (2 by maintainers)
Top Results From Across the Web
Array.sort works in console but not in React Native app
Has anyone seen a time when an Array.sort() would work in some React contexts but not others? javascript · arrays · sorting ·...
Read more >Array.prototype.sort() - JavaScript - MDN Web Docs
The sort() method sorts the elements of an array in place and returns the reference to the same array, now sorted. The default...
Read more >[SOLVED] iOS simulators not showing up - Apple Developer
Hello everyone! This problem first appeared when I updated Xcode 6.1 to version 6.2. At that point, the system let me keep 6.1...
Read more >[Solved]-array not sorting on device - works in Simulator
problem resulted to be in the locale of my iOS device & a different one being used the simulator... One was the same...
Read more >Changelog - Proxyman
[Diff] Add option to sort Header Key in the Diff View ... Fixed: Install certificate to iOS Simulators with simctl does not work...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@mkraft If your issue has to do with sorting dates, you’re in luck.
Originally, I was trying to directly compare two JS Date objects here:
And since the different runtime environments handle dates differently, it was breaking.
Definitely take a look at the Moment.js library. I am using Moment to make sure the formats stay consistent when comparing dates and when I’m hopping between the dev server and static JS bundle.
So this line:
Will give me back the startDateTime (which is a JS Date object), formatted as Moment’s .ISO_8601 format. Now I can compare dates all day long until my fingers fly off.
Here’s my updated block o’ code 4 reference:
Hi, I am having same issue. I am trying to sort contacts and show in FlatList. It works in simulator but when I publish the app for testing on devices it does not sort. Here is my sample code. Please let me know if you guys were able to solve this issue.
Thanks