Javascript Sort Array of Objects By Integer, Date and String

July 27, 2021

By Integer/Float

items.sort((a, b) => a.age - b.age)

By Date

items.sort((a, b) => b.created - a.created )

By String

items.sort((a, b) => a.name.localeCompare(b.name) )

References:

This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.