All pastes #765534 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-11-08 03:09 UTC
rendered paste body
CHALLENGE: $order
SUMMARY: You are required to make an alias that will order numbers and letters. This challange will be broken up into 3 groups
DUE: 15th of november (send entries to jenno07)

[b]Group 1:[/b]
You are only required to order the numbers 1 to 9 inclusive in ascending order
Examples:
$order(5 2 7 3 6) = 2 3 5 6 7
$order(3 3 2 1 5 9) = 1 2 3 3 5 9
NOTE: Spaces are not required in the output. You can return 2 3 5 6 7 or 23567 for the first example


[b]Group 2:[/b] 
This is the same as Group 1 except using numbers from 1 to 100 with an optional 2nd paramater 'r'
if $2 is specified the output must be returned in reverse.
Examples:
$order(5 2 9 1 6 2,r) = 9 6 5 2 2 1
$order(5 2 9 1 6 2) = 1 2 2 5 6 9
NOTE: In this challenge the spaces are required in the output


[b]Group 3:[/b]
Similar to group 2 except using numbers 1 to 100 AND lower case letters from a-z 
When ordering numbers should be considered to precede letters 
Examples:
$order(5 g 9 h u 6) = 5 6 9 g h u
$order(5 g 9 h u 6,r) = u h g 9 6 5
$order(a c g j e h) = a c e g h j
$order(a c g j e h,r) = j h g e c a

[b]Global Rules:[/b]
No sockets/Coms/DLL's
No addtok/deltok/findtok/gettok/instok/matchtok/numtok/puttok/remtok/reptok/sorttok/wildtok 
No /filter
No /window
No regex in ANY form
All invalid formats must return $false
Vars/hash tables etc do not need to be cleaned up - but the alias must work consecutively

[b]Invalid formats: - The following cases must return $false[/b]
$order(a aa aaa)  - each token in $1 must only be 1 character long
if $2 exists and ISN'T r
if $3 exists

[b]Notes:[/b]
No capital letters will be used so you dont need to worry about them
With group 2 and 3 Letters/numbers need to be spaced
Only alphanumeric characters will be tested - IE numbers and letters only
I will make a test alias tomorrow and if it passes the alias it will be considered valid
Will be judged on code size