Editorial Workflows

Shuffle List

public workflow

Install Workflow...

This workflow contains at least one Python script. Only use it if you trust the person who shared this with you, and if you know exactly what it does.

I understand, install the workflow!

This is a workflow for Editorial, a Markdown and plain text editor for iOS. To download it, you need to view this page on a device that has the app installed.

Description: Converts the current document to a list, with one item per line. Shuffles this list, then chooses k number of items per group and prints. Randomly draws an additional number of items as needed to complete group.

Shared by: samuelkordik

Comments: Comment Feed (RSS)

There are no comments yet.

+ Add Comment

Workflow Preview
Document Text ?
Folded Text
  • Include
  • Replace with:
Run Python Script ?
Source Code
# coding: utf-8

import workflow
import dialogs
import os
import numpy as np
import console

text = workflow.get_input()
action_out = ""

def prout (str):
	global action_out
	action_out += str + '\n'

lines = text.split('\n')
lines = lines[0:len(lines)-1]
print lines


# Ask for number of options per group
choose = dialogs.form_dialog('Items per Group',[{'type': 'number', 'key':'k','value':'3'}])
if choose is None:
	prout('Action cancelled, returning shuffled list.')
	i = 0
	for name in lines:
		prout( str(i+1) + '.\t' + name )
		i += 1
	n = len(lines)
	prout('Choosing ' + choose['k']+' from '+str(n)+'...\n')
	i = int(choose['k'])
	group = 1
	for name in lines:
		if i == int(choose['k']):
			prout('\n===== GROUP '+str(group)+' =====')
			i = 0
			group += 1
		prout( str(i+1) + '.\t' + name)
		i += 1
	remaining = n%int(choose['k'])
	remaining = int(choose['k']) - remaining
	if remaining > 0:
		remainder = lines[0:remaining]
		for name in remainder:
			prout( str(i+1) + '.\t'+name)
Create Document ?
Shuffled List.txt
Open in Editor