Previous: Deleting Records, Up: Editing Records


4.3 Sorting Records

In the example above, note the existence of the %sort: Title line. This field was discussed previously (see Sorted Output) and, as mentioned, does not imply that the records need to be stored in the recfile in any particular order.

However, if desired, you can automatically arrange the recfile in that order using recfix with the --sort flag. After running the command

     $ recfix --sort stock.rec

the file stock.rec will have its records sorted in alphabetical order of the Title fields, thus:

     %rec: Item
     %type: Expiry date
     %sort: Title
     
     Title: Emergency Rations
     Expiry: 10 August 2009
     
     Title: First Aid Kit
     Expiry: 2 May 2009
     
     Title: Liferaft
     Expiry: 2 March 2009