Action

Sort draft lines by days

Posted by @scripts4drafts, Last update about 1 year ago

This list will be sorted by days:
Tuesday. Chicken
Monday. Pasta
Sunday. Tacos

Steps

  • script

    // Draft lines are sorted according to the order of the days array
    // In each line, the day name must be followed by a dot then a space
    // if some lines have no day name, they are placed at the beginning of draft
    let days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'].map(d => `${d}.`);
    draft.content = draft.lines.sort(function(a, b) {return days.indexOf(a.split(' ')[0]) - days.indexOf(b.split(' ')[0])}).join('\n');
    draft.update();

Options

  • After Success Default
    Notification Info
    Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.