Home Accessibility Courses Twitter The Mouth Facebook Resources Site Map About Us Contact
 
For 2021 - online Python 3 training - see ((here)).

Our plans were to retire in summer 2020 and see the world, but Coronavirus has lead us into a lot of lockdown programming in Python 3 and PHP 7.
We can now offer tailored online training - small groups, real tutors - works really well for groups of 4 to 14 delegates. Anywhere in the world; course language English.

Please ask about private 'maintenance' training for Python 2, Tcl, Perl, PHP, Lua, etc.
Sorting by key or by comparator - Perl 6

You can sort lists / arrays in Perl 6 - but unlike previous Perl versions, you only need to give a single key expression in your snippet of sort code, rather than instructions on how to compare two values. Of course, since Perl is still eclectic, the old way remains supported too!

Here is an example in which I sorted a list, replacing the previous list. Each item being sorted is itself a list, and I've sorted by the fifth element (element no. 4) of those internal lists.

  @opposite = @opposite.sort({@$^a[4]});

Complete code - [here]. Of course, since Perl never uses 3 characters where 2 will do, my example may be awful hard to follow at first ... please ask me about Perl 6 training courses, currently under development - happy to help with bespoke training requirements from February 2016.

Note - in the move from Python 2 to Python 3, sorting has changed in that language too - also moving from a comparator to a key approach - so it's something we're very familiar with when we come to teach you!
(written 2016-01-03)

 
Associated topics are indexed as below, or enter http://melksh.am/nnnn for individual articles
P600 - Perl 6
  [582] DWIM and AWWO - (2006-01-30)
  [2816] Intelligent Matching in Perl - (2010-06-18)
  [4604] Perl - version 6 - official version launched at Christmas - (2016-01-02)
  [4605] Hello World - in Perl 6 - (2016-01-02)
  [4606] Using Perl 6 to analyse and report on data - (2016-01-02)
  [4607] Classes and object - first steps in Perl 6 - (2016-01-02)
  [4608] Introspecion in Perl 6 - (2016-01-02)
  [4609] Mapping an array / list without a loop - how to do it in Perl 6 - (2016-01-03)
  [4611] Hungarian, Camel, Snake and Kebab - variable naming conventions - (2016-01-03)
  [4620] Perl 6 - a Practical Extraction and Reporting example! - (2016-01-11)


Back to
Mapping an array / list without a loop - how to do it in Perl 6
Previous and next
or
Horse's mouth home
Forward to
Hungarian, Camel, Snake and Kebab - variable naming conventions
Some other Articles
PC Plod - alive and scaremongering in Wiltshire?
Our best hotel customers help us ... to help them ... be our best customers.
TransWilts - robust these days - no longer the first service to be cancelled
Sorting by key or by comparator - Perl 6
4759 posts, page by page
Link to page ... 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96 at 50 posts per page


This is a page archived from The Horse's Mouth at http://www.wellho.net/horse/ - the diary and writings of Graham Ellis. Every attempt was made to provide current information at the time the page was written, but things do move forward in our business - new software releases, price changes, new techniques. Please check back via our main site for current courses, prices, versions, etc - any mention of a price in "The Horse's Mouth" cannot be taken as an offer to supply at that price.

Link to Ezine home page (for reading).
Link to Blogging home page (to add comments).

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2021: 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho

PAGE: http://www.wellho.net/mouth/4610_Sor ... erl-6.html • PAGE BUILT: Sun Oct 11 16:07:41 2020 • BUILD SYSTEM: JelliaJamb