'Why is my list not rendering on the page using sort ()?

I have this project in react where I need to sort my data in desc and asc. My new list is not being rendered on the page. Here is just a snippet of the code.



const list = [
    {
      Id: "1",
      Time: "2022-01-18T14:52:48Z",
    },
    {
     Id: "3",
     Time: "2022-01-18T15:05:28Z",
    },
    {
      Id: "2",
      Time: "2022-01-18T16:57:58Z",
    },
    {
      Id: "0",
      Time: "2022-01-18T16:00:28Z",
    },
  ];

  list.sort((firstItem, secondItem) => firstItem.Id - secondItem.Id);



Solution 1:[1]

     ASC :  list.sort(function(a, b) {
           return a.Id - b.Id;
         });


    DESC:  list.sort(function(a, b) {
           return b.Id - a.Id;
         });

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 dontay