Skip to content

Instantly share code, notes, and snippets.

@mattcassinelli
Created October 27, 2014 00:28
Show Gist options
  • Save mattcassinelli/9cbb2184757f61a132ec to your computer and use it in GitHub Desktop.
Save mattcassinelli/9cbb2184757f61a132ec to your computer and use it in GitHub Desktop.
Sort lines in Drafts 4
function generate(s){
var temp = new Array();
temp = s.split('\n');
temp.sort();
var result = "";
var i;
for(i=0; i<temp.length; i++) {
result += temp[i] + "\n";
}
return result;
}
setSelectedText(generate(getSelectedText()))
@mattcassinelli
Copy link
Author

Script written by Gabe Weatherhead on Macdrifter: http://www.macdrifter.com/2014/10/drafts-4-keyboard-scripts.html#fn:sort

Installation instructions:
To add this to the extra keyboard row in Drafts 4, do this:

  1. Click the pencil icon on the extra keyboard row to edit the keys
  2. Add a new key with the plus in the upper right corner
  3. Choose a "Script" type key
  4. Add the Javascript, label and voice over.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment