0

I have the fallowing data:

const data = [
    {
        data1:
        {
            title: 'Scaling 100k users',
            upvotes: 72,
            date: '2019-01-21'
        }
    },
    {
        data2:
        {
            title: 'the emu War',
            upvotes: 24,
            date: '2019-10-21'
        }
    },
    {
        data3: {
            title: 'Alphabet earnings',
            upvotes: 22,
            date: '2019-11-23'
        }
    },
    {
        data4: {
            title: 'A message to our customers',
            upvotes: 12,
            date: '2019-01-24'
        }
    },
    {
        data5: {
            title: 'Simple text editor has 15k monthly users',
            upvotes: 7,
            date: '2019-12-31'
        }
    },
    {
        data6: {
            title: 'Artificial Mountains',
            upvotes: 75,
            date: '2019-11-22'
        }
    },
    {
        data7: {
            title: 'What\'s SAP',
            upvotes: 1,
            date: '2019-11-21'
        }
    },
    {
        data8: {
            title: 'Eating glass',
            upvotes: 172,
            date: '2019-01-01'
        }
    }
]

I want to obtain a list sorted by values:

1.from more to less upvotes

2.from more recent to less recent date

It is due an homework I am doing and I think if I achive this I can be a better programmer, but I am only obtaining individual sorted values

thank to all forr your time

  • 1
    btw, you have a strange naming scheme of `data*n*`. your data has no twice or more of same upvotes ... – Nina Scholz May 14 '21 at 17:10
  • could be possible...it is just an excercise I've made for myself but with this answer cauld be very helpfull for future dilemas hehe: https://es.stackoverflow.com/questions/451996/lista-de-objetos-como-ordenarla-por-numero-y-por-fecha/452020#452020 – Maykel Contreras Camacho May 14 '21 at 17:34

0 Answers0