Quote:
Originally Posted by ownedbycats
Is there a function that sorts a list into a user-defined order?
Context: I have a text column that may return results in a list-string like "foo, bar, foo, foo, foobar."
Using Action Chains, I'd like to:
a) Sort the entries in a user-defined order (e.g. "foobar, bar, foo, foo, foo)
b) Select the first item of this sorted list
And then replace the string with that.
(Additional context: When FanFicFare downloads an anthology of multiple fics, it concenates all the ratings into an unsorted string like "General Audiences, Mature Audiences, Explicit, Teen and Up Audiences, Not Rated." In order, I want to pick the first of Explicit > Mature > Teen > General > Not Rated.)
|
No. The only way to do it that I can think of is to make a list containing all possible items, then loop through that list using for. If the actual list contains the current item then add it to the result list, otherwise skip it. Something like this:
Code:
program:
possibles = 'Explicit, Mature, Teen, General, Not Rated';
actuals = 'foo, Mature, Teen, Explicit';
answer = '';
for item in possibles:
if '^' & item & '$' inlist actuals then
answer = item;
break
fi
rof;
answer
Quote:
edit: can I check just one column with a first_non_empty?
|
I don't understand. Are you asking if you can have only one rule? Yes.