79292166

Date: 2024-12-18 18:51:31
Score: 0.5
Natty:
Report link
function customSort(table, critera) {

    var value = display(table, critera);
    var result = value.sort((a, b) = >b - a);
    return result.join(",")
}

function print(func) {
    console.log(customSort(func))
}

function display(a, key) {

    var finalvalue = [];
    for (i = 0; i < myarray.length; i++) {
        finalvalue.push(myarray[i].key);

    }

    return finalvalue;
}

var myarray = [{
    key: 6
},
{
    key: 9
},
{
    key: 2
},
{
    key: 1
},
{
    key: 12
},
{
    key: 63
},
{
    key: 20
},
{
    key: 25
},
{
    key: 13
},
{
    key: 19
},
{
    key: 32
},
{
    key: 70
},
{
    key: 14
},
{
    key: 7
},
{
    key: 8
}];

print(display(myarray, 'key'));

customSort(myarray, 'key');
print(display(myarray, 'key'));
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: sachin sahu