in reply to How can I sort this data on the fourth field?
The output is:#!/usr/bin/perl use warnings; use strict; package main; my %data_set = (); while(<DATA>) { my @row = split/\s+/, $_; $data_set{$row[3]} = [ $row[0], $row[1], $row[2] ]; } foreach ( sort { $b <=> $a } keys %data_set ) { printf "%-6d -> %-4d %-7s %-6d\n", $_, $data_set{$_}->[0], $data_set{$_}->[1], $data_set{$_}->[2] +; } __DATA__ 0 TOTAL 11997 26981 0 root 1089 2594 1 daemon 0 0 594 pipmp01 591 1151 958 maestro 335 685
C:\Code>perl hashsort.pl 26981 -> 0 TOTAL 11997 2594 -> 0 root 1089 1151 -> 594 pipmp01 591 685 -> 958 maestro 335 0 -> 1 daemon 0
|
|---|