find a way of breaking (or accessing) your fields
individually. Then sort, search, whatever...
unix /etc/passwd contains 7 fields separated by ":"
to sort by 3rd field (user id):
perl -e '@a=<>; @b = sort {
@aa=split /:/,$a;
@bb=split /:/,$b;
$aa[2] <=> $bb[2] } @a; print...