Linked Questions

13 votes
1 answer
12k views

Is it possible, rather easily, to sort an array of objects by an array of IDs? Here's an example: [{ id: "A", name: "John" }, { id: "B", name: "Bobby" }, { id: "C", name: "...
MortenMoulder's user avatar
6 votes
2 answers
11k views

Possible Duplicate: JavaScript - Sort an array based on another array of integers Javascript - sort array based on another array If I have an array like this: ['one','four','two'] And another ...
David Hellsing's user avatar
5 votes
3 answers
19k views

I have an array that looks like this: order = [ "foo", "bar", "baz" ]; This array contains the attribute values I would like to sort my array of objects by. I want to sort the data so that all the ...
Team Cafe's user avatar
  • 311
-2 votes
4 answers
3k views

I have a Javascript array of object. Each of them has an integer property type in a range between 1 and 4. Depending on the client, I want to sort the array members by an individual number sequence of ...
André Reichelt's user avatar
3 votes
5 answers
111 views

I have variable that defines the order of objects like this: const order = ['large', 'medium', 'small']; I want to match that order of data array objects using names from order array: const data = [{...
Michał Lach's user avatar
  • 1,278
2 votes
1 answer
749 views

I have some weekday-based data as follows: [{ "dayOfWeek": "TUESDAY", "startTime": "19:30:00", "endTime": "21:15:00" }, { "dayOfWeek": "SATURDAY", "startTime": "19:15:00", "...
j_d's user avatar
  • 3,120
2 votes
2 answers
166 views

I have an array peeps = [{name: "Mike", age: 31},{name: "Dave", age: 31},{name: "Delta", age: 31},{name: "Clint", age: 31}] And I need to sort them by an ...
UXCODA's user avatar
  • 1,246
-4 votes
2 answers
604 views

I have two arrays. itemsArray = [ { id: 8, name: 'o'}, { id: 7, name: 'g'}, { id: 6, name: 'a'}, { id: 5, name: 'k'}, { id: 4, name: 'c'} ] sortArray = [4,5] How can i sort itemsArray by sortArray (...
Serdar's user avatar
  • 53
1 vote
2 answers
242 views

How could I sort an array of events by the month they are occuring in? For instance, I want to sort this events array: [{ event: 'prom', month: 'MAY' }, { event: 'graduation', month: 'JUN' }, { ...
Ultima's user avatar
  • 23
1 vote
4 answers
121 views

How to sort an array using Array.prototype.sort() by type and currency in this order: debit => credit => external => loan and if there are several currencies in the same type, then arrange ...
BERTOLDO's user avatar
  • 223
0 votes
1 answer
273 views

I have an array of items that I want to sort based on the category property: const arr = [{ id: 1, category: 'bar' }, { id: 4, category: 'baz' }, { id: 5, category: 'foo' }] What I want ...
undefined's user avatar
  • 6,974
0 votes
4 answers
132 views

So I have an array of objects similar to below: var objs = [ { key: 'address', value: '1234 street' }, { key: 'nameAndTitle', value: 'John Smith, CEO' }, { key: 'contactEmail', value: '...
Zach Starnes's user avatar
  • 3,208
0 votes
2 answers
201 views

I have an array like this: var data = ['High', 'Low', 'Medium']; This data array is created dynamically. So, it may have all 3 values or only 2 values or 1 value. Regardless of the values in the ...
Jake's user avatar
  • 26.2k
0 votes
4 answers
104 views

How can I sort an array of arrays based on another array? Example: const dataset = [ [ 'red', [{name: 'Apple car'}] ], [ 'blue', [{name: 'Toothpiece'}] ], [ 'orange', [{name: 'Sun'}] ], [ '...
marielle's user avatar
  • 484
1 vote
2 answers
189 views

Lets say I have a base array let object2 = ["DotNet", "ETL", "Hadoop", "Java", "Oracle", "Pega", "MainFrame"] I want to order this second array in the same order of the base array let object1 = [{...
Terrance Jackson's user avatar

15 30 50 per page
1
2 3 4 5 6