About 51 results
Open links in new tab
  1. Sort array by firstname (alphabetically) in JavaScript

    I got an array (see below for one object in the array) that I need to sort by firstname using JavaScript. How can I do it? var user = { bio: null, email: "user@domain.example",

  2. javascript - Sort objects in an array alphabetically on one property of ...

    Here is a simple function you can use to sort array of objects through their properties; it doesn't matter if the property is a type of string or integer, it will work.

  3. Sort array alphabetically javascript - Stack Overflow

    Feb 12, 2017 · 8 Yes. If you look at the .sort() method on MDN it states the case when the compare function parameter is omitted: Specifies a function that defines the sort order. If omitted, the array is …

  4. How can I sort a Javascript array alphabetically? [duplicate]

    Sep 29, 2023 · 1 Your array already contains strings of names where the last name is the first part of the string, so you can just call the .sort() method. Oh, and your array contains a typo: 'Blake, 'William' …

  5. How to sort strings in JavaScript - Stack Overflow

    Oct 22, 2014 · list.sort(function (a, b) { return a.attr - b.attr }) but found that - doesn't appear to work with strings in JavaScript. How can I sort a list of objects based on an attribute with type string?

  6. Simple function to sort an array of objects - Stack Overflow

    I would like to create a (non-anonymous) function that sorts an array of objects alphabetically by the key name. I only code straight-out JavaScript so frameworks don't help me in the least. var p...

  7. javascript - Sort Array of numeric & alphabetical elements (Natural ...

    Dec 7, 2010 · If you can always assume numbers and strings of unmixed alphas, I would just divide and conquer. slice out numbers into a new array using typeof. Sort both independently and then just join …

  8. How to sort by length and then alphabetically - Stack Overflow

    16 Assume I had the following Javascript array. How do you sort by length, then alphabetically? Assume the following array:

  9. javascript - Sorting an array of objects by property values - Stack ...

    While it is a bit of an overkill for just sorting a single array, this prototype function allows to sort Javascript arrays by any key, in ascending or descending order, including nested keys, using dot …

  10. How to perform case-insensitive sorting array of string in JavaScript ...

    I have an array of strings I need to sort in JavaScript, but in a case-insensitive way. How to perform this?