Skip to content

How to throw specific item to the end

elad ben aderet edited this page Dec 17, 2020 · 1 revision

I needed to sort a list by string ex: all items with the property "source"

if it equals to "Unlinked" it should drop to the end of the list

if it doesn't equals to "Unlinked" it should be shifted to start of the array

I managed to do this like this:

sortArray(list, {
   by: "source",
   computed: {
     total: source => (source === "Unlinked" ? 1 : 0),
   },
 });