• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: Array.sort() on multiple properties

Resolved: Array.sort() on multiple properties

0
By Isaac Tonny on 17/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

I have an array, productData with multiple properties. This is how I currently sort the array by monthlyCost, ascending.
How can I modify this to sort all items by a boolean property isPromoted, followed by monthlyCost?
My array should start with all items where isPromoted == true sorted by monthlyCost, then all items where isPromoted == false sorted by monthlyCost.
The unary plus is optional in plain JavaScript, but in a TypeScript context, you’ll need to be explicit about the conversion to number and apply +.

If you have better answer, please add a comment about this, thank you!

javascript sorting
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: Input Focus between two React Components

02/04/2023

Resolved: linq2db throws exception when filtering by nested collection

02/04/2023

Resolved: Table data is coming as empty in React

02/04/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.