RosettaCodeData/Task/Sort-an-array-of-composite-structures/UNIX-Shell/sort-an-array-of-composite-structures.sh
Ingy döt Net 68f8f3e56b all tasks
2013-04-11 01:07:29 -07:00

28 lines
316 B
Bash

list="namez:order!
name space:in
name1:sort
name:Please"
newline="
"
dumplist() {
(
IFS=$newline
for pair in $list; do
(
IFS=:
set -- $pair
echo " $1 => $2"
)
done
)
}
echo "Original list:"
dumplist
list=`IFS=$newline; printf %s "$list" | sort -t: -k1,1`
echo "Sorted list:"
dumplist