0

I need to sort an array of objects by columnId, preferably using lodash. The array is like this:

lines: lineId: 1,lineAbbreviation: "",workingListId: 4208,workingListType: 0,sortOrder: 0,holdType: 1,[tripSummary: - [- {columnId: 24,columnType: 1,value: "2.00"},- {columnId: 28,columnType: 5,value: "0.66"},- {columnId: 29,columnType: 6,value: "0.00"},- {columnId: 23,columnType: 0,value: "152.56"},- {columnId: 25,columnType: 2,value: "24"},- {columnId: 26,columnType: 3,value: "30"},- {columnId: 27,columnType: 4,value: "101.36"},- {columnId: 30,columnType: 7,value: "0.00"},- {columnId: 31,columnType: 8,value: "0.5"},- {columnId: 32,columnType: 9,value: "0"},- {columnId: 33,columnType: 10,value: "1"}]}]

If this is not enough info let me know. I don't know what else I can add though. Its pretty straight forward sorting the array, I just cant figure out how to do it.

UPDATE What I need is the tripSummary to be sorted by columnID. there are more than one line object, actually there is about 200+, I only added one because there would be way too much code. There is one tripSummary object per line object. So in the end each line will be sorted by tripSummary.columnId. Hope this clears more up.

6
  • 3
    I don't understand what the '-' signs are doing in there. Commented Feb 3, 2017 at 17:30
  • What have you tried? The documentation is pretty straightforward, so you may have to be more specific about what you're stuck on. Commented Feb 3, 2017 at 17:34
  • @rasmeister it seem he copy from browser extension to format json data Commented Feb 3, 2017 at 17:40
  • @rasmeister - yes I copied the json from a chrome extension. Commented Feb 3, 2017 at 17:51
  • 1
    Here is your solution. Check out codepen.io/cmlonder/pen/oBWNyY Commented Feb 3, 2017 at 19:43

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.