Home > front end >  Js array object sort of problem
Js array object sort of problem

Time:09-15

This is the result of the console output, with the most simple array object sorting method, the blue part can sort but not green, I think the question should be out in the red part, do you have any good solution???????






Newlist is output, here is the code,
` ` `
The console. The log (newlist. Sort (function (a, b) {return a.r ating - b.r ating}))

` ` `



Thank you very much!

CodePudding user response:

Make sure each array element has a first rating this property, you can in the sorting method, the print look at each element of the rating value

CodePudding user response:

reference 1/f, BuBu high lighter reply:
make sure each array element has a first rating this property, you can print each element in the sorting method, the rating value look

Each array element

CodePudding user response:

What are you the sort here is worth

CodePudding user response:

refer to the third floor is a little small lewd honest reply:
sort here is worth what you

Ascending and descending order this is

CodePudding user response:

refer to the third floor is a little small lewd honest reply:
sort here is worth what you

Another array object such as the blue line that can be sorted but not a rating

CodePudding user response:

For example you here?
Said don't understand you said where is ascending and descending order

CodePudding user response:

I'm here to see the rating is a floating point number and duration is a integer ~ ~

CodePudding user response:

refer to 7th floor is a little small lewd honest reply:
I see here the rating is a floating point number and duration is a integer ~ ~

The console. The log (newlist. Sort (function (a, b) {return a.r ating - b.r ating})) use of this sort

CodePudding user response:

refer to the eighth floor Eric tan is not round reply:
Quote: refer to 7th floor is a little small lewd honest reply:
I see here the rating is a floating point number and duration is a integer ~ ~

The console. The log (newlist. Sort (function (a, b) {return a.r ating - b.r ating})) with this sort of

Ow should be a floating point number! Thank you for your bosses
  • Related