#!/bin/sh
#
#  tgrsort [file] -- sort TIGER line chains
#
#  Sort keys are:
#
#  1. CFCC feature class, in this order:
#	boundary
#	water
#	other topographic feature  (rare)
#	road
#	railroad
#	pipeline, power line, etc.
#	landmark
#	unclassified
#
#   2. Major category, largest (least significant) first
#
#   The feature class and category sorting is chosen so that more important
#   chains are drawn later, obscuring lesser chains, instead of the reverse.
#
#   Note that this sorting can reverse the positions of the first two lines
#   of the file (the min/max lines), but tgrmap.icn can handle that.

TR1=FHEABCDX
TR2=JKLMNPQR

cat $1 |
tr $TR1 $TR2 |
sort -t: -k 1.1,1.1 -k 1.2,1.3r -k 1.4 |
tr $TR2 $TR1
