Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6076441
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:36:29+00:00 2026-05-23T10:36:29+00:00

my @output = map $_->[0], sort{$a->[1] <=> $b->[1]} map [$_,-s $_], @array; Can someone

  • 0
my @output =
map $_->[0],
sort{$a->[1] <=> $b->[1]}
map [$_,-s $_],     
@array;   

Can someone explain the code in more detail? I can’t get head or tail of it ..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T10:36:30+00:00Added an answer on May 23, 2026 at 10:36 am

    Read from the bottom up:

    @array
    

    An array (of filenames, given later usage).

    map [$_,-s $_],
    

    For each filename, get a reference to a two element anonymous array, with the first element being the filename and the second element, the byte size of the file. map returns a list of these array references.

    sort{$a->[1] <=> $b->[1]}
    

    Sort the list of array references by increasing file size.

    map $_->[0],
    

    Turn the list of array references back into a list of filenames, but now in sorted order.

    my @output =
    

    Save the list in @output.

    This is equivalent in function to:

    my @output = sort { -s $a <=> -s $b } @array;
    

    but only gets the size for each file once instead of once per comparison done by the sort.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For example, how do I get Output.map from F:\Program Files\SSH Communications Security\SSH Secure Shell\Output.map
The output of my JSON call can either be an Array or a Hash.
How can I group map values by 2 different criteria to get the outputs
The output we get when printing C++ sources from Eclipse is rather ugly. Is
The output of eg >>w = whos; returns an array of structs. I would
My output windows is full of The thread 0xe48 has exited with code 0
I have tried almost everything and I can't seem to get my lists to
I am trying to find out where does the output of a Map task
How can i map a date from a java object to a database with
How to sort (any kind of sorting) a key of a map(treemap or hashmap)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.