0

I have a listings and i want to sort it by a certain value, listing.value. Here is the code, i used the sort() but it simply sorts, i want to sort it by the listing.value.

const listings = 
[{
  id: '1',
  name: 'abc',
  value: 201
}, {
  id: '2',
  name: 'def',
  value: 441
}]



<div>
                {listings?.map((listing) => (
                  <div key={listing.id} >
                    <h2>
                        {listing.name}
                   </h2>
                    <p>
                      <b>{listing.value}</b>
                    </p>
                  </div>
                )).sort()}
              </div>

I tried it to sort but sort just sorts it, it don't sort it by the custom value.

0 Answers0