Answer the question
In order to leave comments, you need to log in
How to recognize a function argument as a property of another object?
Tell me how you can
sortAny(contacts: ContactList[], type?: string, direction?: string) {
const sortArr = contacts.sort(function (a, b) {
const x = a.type;
const y = b.type;
if (x > y) {
return 1;
}
if (x < y) {
return -1;
}
return 0;
});
if (direction === 'down') {
return sortArr;
}
if (direction === 'up') {
return sortArr.reverse();
}
return contacts;
}
const x = a.type;
const y = b.type;
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question