#!/usr/local/bin/perl -w # use strict; our @thingsToSort = ( {author => 'bart', title => 'skateboarding'}, {author => 'lisa', title => 'postmodernism'}, {author => 'marge', title => 'hairstyles'}, {author => 'lisa', title => 'THIS BOOK FIRST'}, {author => 'homer', title => 'donuts'}, {author => 'bart', title => 'coolness'}, {author => 'lisa', title => 'eating veggies'}); our $firstAuthor = q(); foreach (@thingsToSort) { next unless $_->{title} eq 'THIS BOOK FIRST'; $firstAuthor = $_->{author}; last; } print map {"$_->[0]->{author}: $_->[0]->{title}\n"} sort { $b->[1] <=> $a->[1] || $b->[2] <=> $a->[2] || $a->[0]->{author} cmp $b->[0]->{author} || $a->[0]->{title} cmp $b->[0]->{title} } map { [ $_, $_->{title} eq 'THIS BOOK FIRST', $_->{author} eq $firstAuthor ] } @thingsToSort;