0

how can i order this array of objects:

var arr= [
  { name: 'Mario', date: '/Date(16487438090000)/' },
  { name: 'Mario', date: '/Date(16987438090000)/' },
  { name: 'Mario', date: '/Date(16887438090000)/' }
]

According to the 'date' property, how can I order from largest to smallest? example I want you to return me an array like this:

[
  { name: 'Mario', date: '/Date(16987438090000)/' },
  { name: 'Mario', date: '/Date(16887438090000)/' }
  { name: 'Mario', date: '/Date(16487438090000)/' },
]
fabrizio
  • 11
  • 4
  • What is the type of the `date` property? Is it just a javascript [`Date`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date?retiredLocale=nl)? – Titulum Jul 29 '22 at 07:49
  • @Titulum yes it just a javascript date – fabrizio Jul 29 '22 at 07:55
  • Since `date`s seem to be constant-length strings, you can even get away with a lexical comparison using `.sort` and `.localeCompare` or whatever. – FZs Jul 29 '22 at 07:58
  • @FZs How can i do? – fabrizio Jul 29 '22 at 08:16

0 Answers0