I need something like the following:
let arr = [...] //array of strings
let resultArr = arr.sort({obj1,obj2 in
if some_condition(obj1, obj2) {
...//return the order of obj1 and obj2 from arr
} else {
return obj1 < obj2
}
})
I saw a lot of questions/answers how to simply sort the array items but no one answers how to store the original order. some_condition
may be any but each array object may be sorted with the original order or with the new one. How to solve this issue?
Example
let arr = ["a", "f", "d", "b", "y", "c", "e"]
//elements "a", "d", "f" conform some_condition
resultArr == ["a", "f", "d", "b", "c", "e", "y"]