<<TableOfContents>>
= SortBy =

== Description ==

The !SortBy macro will take a wiki table of data and sort it by the criteria you specify, similar to the functionality you’d expect from a spreadsheet program.  This macro can be useful for such tasks as building internal phone lists, etc.

== Download & Release Notes ==
|| Download || Release Version || Moin Version || Release Notes ||
|| [[attachment:SortBy-1.7.py]] ||  || 1.7 || Small update to work on 1.7 ||
|| [[attachment:SortBy.py]] ||  || 1.5 & 1.6 ||  ||

== Usage ==
{{{[[SortBy(page, num_headers, column, sort_type [,othercolumn, sort_type]...)]]}}}
== Example ==

Sorting a phone list: 

The following example will take the '!PhonelistData' from another page and sort it {{{<<SortBy(PhoneListData,1,1,alpha)>>}}}

 ||<rowbgcolor="#f1f1f1">'''__Name__''' ||'''__Email__''' ||'''__Phone__''' ||
 || Bill || bill@example.com || x.456 ||
 || Carl || carl@example.com || x.234 ||
 || Albert || albert@example.com || x.123 ||

becomes...

 ||<rowbgcolor="#f1f1f1">'''__Name__''' ||'''__Email__''' ||'''__Phone__''' ||
 || Albert || albert@example.com || x.123 ||
 || Bill || bill@example.com || x.456 ||
 || Carl || carl@example.com || x.234 ||



== Copyright ==
LaneRettig

== License ==

= Bugs =
 * The macro cannot handle unicode, when processing a german umlaut like äöü i get the following error in MoinMoin Version 1.5.8
{{{UnicodeDecodeError 'ascii' codec can't decode byte 0xc3 in position 46: ordinal not in range(128)}}}

= Discussion =
 * See also [[FeatureRequests/SortableTables]].