Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: Sorting Blocks

From: AJMartin:orcon at: 29-Jan-2006 9:38

> How do you sort a block of blocks on an element other than the first? > > For example: > > db: [ > ["bob" "Smith" "12"] > ["dan" "murphy" "25"] > ["mike" "Coogan" "6"] > ] > > How do I sort by last name or by age >> DB: ["Bob" "Smith" 12 "Dan" "Murphy" 25 "Mike" "Coogan" 6]
== ["Bob" "Smith" 12 "Dan" "Murphy" 25 "Mike" "Coogan" 6]
>> sort/skip/compare DB 3 2
== ["Mike" "Coogan" 6 "Dan" "Murphy" 25 "Bob" "Smith" 12]
>> sort/skip/compare DB 3 3
== ["Mike" "Coogan" 6 "Bob" "Smith" 12 "Dan" "Murphy" 25]
>> sort/skip/compare/reverse DB 3 3
== ["Dan" "Murphy" 25 "Bob" "Smith" 12 "Mike" "Coogan" 6]
>> help sort
USAGE: SORT series /case /skip size /compare comparator /part length /all /reverse DESCRIPTION: Sorts a series. SORT is an action value. ARGUMENTS: series -- (Type: series port) REFINEMENTS: /case -- Case sensitive sort. /skip -- Treat the series as records of fixed size. size -- Size of each record. (Type: integer) /compare -- Comparator offset, block or function. comparator -- (Type: integer block function) /part -- Sort only part of a series. length -- Length of series to sort. (Type: integer) /all -- Compare all fields /reverse -- Reverse sort order I hope that helps. AJ Martin Auto-surfing for 4% daily at: http://www.surfmunkee.com/?ref=7295 E-Gold: http://2255725.e-gold.com/