Tabulator list editor sorting

I have a column whose editor is a list. I am trying to sort the items in the editor list according to the following logic:

The editor parameters values is an array of vendors in the form of

{1: "amazon", 2: "eBay", 3: "stock", 4: "fuel"}

Some of them belong to a special category and have to be displayed at the top of the list, let’s say items 3 and 4, which are defined in an array called globalOrder in the form of [{id: 3, order: 1}, {id: 4, order: 2}]. id corresponds aValue/bValue and order is the desired order.

In my approach so far, I am creating a sort function called “sort_vendor_id” and setting in the column editorParams:

{sort: function(aLabel, bLabel, aValue, bValue) {sort_vendor_id(aLabel, bLabel, aValue, bValue, globalOrder);}}.

If a value is not in the id column of globalOrder it’s order should not be affected.

I have been unable to interpret this logic in the sort_vendor_id function, so any help will be very welcome!

I have tried to extract the id column from globalOrder after sorting it properly but then I am stuck with how to put my logic into code.