emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Orgmode] Re: Feature Request: Assort a subtree randomly ?


From: Matt Lundin
Subject: [Orgmode] Re: Feature Request: Assort a subtree randomly ?
Date: Sat, 29 Jan 2011 09:42:05 -0500
User-agent: Gnus/5.110011 (No Gnus v0.11) Emacs/24.0.50 (gnu/linux)

"Alan E. Davis" <address@hidden> writes:

> Let's say I have a subtree, of review materials, for example.  I would
> like to randomize the order of the elements.  I would like to have the
> option to randomize the subtree in some different ways:
>
>     1.  sort the members of one subtree that is a list, randomly.
>     2.  sort all the headlines, randomly.
>     3.  sort the subtrees randomly, and the lists within each
> sub-subtree also randomly, ad nauseum.
>
> I have written a sort routine in elisp.  It's been many long years ago,
> but I remember that the basis support for writing sorts is pretty
> general.
>
> Suppose I had time to do this.  What would I need to look at?
>

You can use the custom function in the sort command to supply org-sort
with a random number. When calling org-sort, note the function option
presented:

,----[ C-c ^ (org-sort)
| Sort %s: [a]lpha  [n]umeric  [p]riority  p[r]operty  todo[o]rder  [f]unc
| [t]ime [s]cheduled  [d]eadline  [c]reated
| A/N/T/S/D/C/P/O/F means reversed:
`----

You could thus write a quick function, using whatever amount of
randomness you want:

--8<---------------cut here---------------start------------->8---
(defun my-org-random-sort ()
  (random 1000))
--8<---------------cut here---------------end--------------->8---

Then on the appropriate subtree/table/list, type:

C-c ^ f my-org-random-sort

> Of course, my need is today, to sort review materials for my students
> in random order.

Sorry this response comes a little to late. :)

Best,
Matt



reply via email to

[Prev in Thread] Current Thread [Next in Thread]