Files are sorted by columns by Perl

Source: Internet
Author: User

Perl is often used to process files in CSV format. Such files are similar to two-dimensional arrays, so operations on two-dimensional arrays are actually performed.
For such a row and column table, we often need to sort by a column or by a column first and then by another column. For specific operations, see the following implementation of "tables:

  1.  
  2. #! /Usr/bin/perl
  3. My @ line;
  4. While (<>)
  5. {
  6. Chomp;
  7. Push @ line, [split];
  8. }
  9. Foreach (sort {$ A-> [0] <=> $ B-> [0] or $ A-> [1] <=> $ B-> [1] or $ A-> [2] <=> $ B-> [2]} @ line)
  10. {
  11. Print @ $ _, "N ";
  12. }

Note:
It is best not to use large files in this way.
This script will move all the data to the memory.

www.bbilo.com/gbdfzmzcwww.bbilo.com/gbdfbjlwww.bbilo.com/gbdfylyqwww.bbilo.com/mdgbdfrqrhwww.bbilo.com/gbdfmdyjmwww.bbilo.com/mdgbdfaqmwww.bbilo.com/gbdfkmdlwww.bbilo.com/gbdfxwzwww.bbilo.com/gbdfwtzxwww.bbilo.com/gbdfdmswww.bbilo.com/gbdfzcwww.bbilo.com/gbdfsywww.bbilo.com/gbdfwzxwww.bbilo.com/gbdfnyqbwww.bbilo.com/gbdfzjwww.bbilo.com/gbdfdzwww.jdcvv.com/gbdfylwwww.jdcvv.com/gbdfwww.jdcvv.com/gbdfkhwww.jdcvv.com/gbdfylwww.jdcvv.com/gbdfhykhwww.jdcvv.com/1659988_comgbdfwww.jdcvv.com/gbdfshywww.jdcvv.com/gbdfgwwww.jdcvv.com/gbdfwtwww.jdcvv.com/gbdfylcwww.jdcvv.com/gbdfdlwww.jdcvv.com/gbdfxcwww.jdcvv.com/gbdfyldlwww.jdcvv.com/gbdfylkhwww.jdcvv.com/gggbdfylcwww.jdcvv.com/gbdfsjzmdlwww.jdcvv.com/gbdfzmnyqwww.jdcvv.com/gbdfyjwww.jdcvv.com/gbdfxmfwww.jdcvv.com/szdmdgbdfwww.jdcvv.com/mdgbdfwww.jdcvv.com/gbdfdlkhwww.jdcvv.com/gbdfkh1581260www.jdcvv.com/gbdfylhbwzwww.jdcvv.com/gbdfyqwww.jdcvv.com/sygbdfylwww.jdcvv.com/gbdfylzmyqwww.jdcvv.com/gbdfylyflmwww.jdcvv.com/gbdfylcznlwww.jdcvv.com/gbdfwzwww.jdcvv.com/gbdftzwww.jdcvv.com/gbdfdhwww.jdcvv.com/gbdfsjwww.jdcvv.com/gggbdfwww.jdcvv.com/gbdfgfwwww.jdcvv.com/gbdfkhwwww.jdcvv.com/gbdfshwww.jdcvv.com/gbdfsjxzwww.jdcvv.com/gbdfylsjxzwww.jdcvv.com/gbdfwfmwww.jdcvv.com/gbdfdtkhwww.jdcvv.com/gbdfhywww.jdcvv.com/gbdfrhkhwww.jdcvv.com/gbdfzdlwww.jdcvv.com/gbdfwwww.jdcvv.com/gbdfdtkmdlwww.jdcvv.com/gbdfglwwww.jdcvv.com/gbdfxjwwww.jdcvv.com/gbdfwtkhzxwww.jdcvv.com/gbdfwtdhkhwww.jdcvv.com/gbdfwkhwww.jdcvv.com/gbdfwthykhwww.jdcvv.com/gbdftgywww.jdcvv.com/gbdfylwzwww.jdcvv.com/gbdfzmzcwww.jdcvv.com/gbdfbjlwww.jdcvv.com/gbdfylyqwww.jdcvv.com/mdgbdfrqrhwww.jdcvv.com/gbdfmdyjmwww.jdcvv.com/mdgbdfaqmwww.jdcvv.com/gbdfkmdlwww.jdcvv.com/gbdfxwzwww.jdcvv.com/gbdfwtzxwww.jdcvv.com/gbdfdmswww.jdcvv.com/gbdfzcwww.jdcvv.com/gbdfsywww.jdcvv.com/gbdfwzxwww.jdcvv.com/gbdfzjwww.jdcvv.com/gbdfdzwww.vqjqu.com/gbdfwww.vqjqu.com/gbdfkhwww.vqjqu.com/gbdfylwwww.vqjqu.com/gbdfylwww.vqjqu.com/gbdfhykhwww.vqjqu.com/1659988_comgbdfwww.vqjqu.com/gbdfdhtzwww.vqjqu.com/gbdfylptwww.vqjqu.com/gbdfshywww.vqjqu.com/gbdfzxkhwww.vqjqu.com/gbdfgwwww.vqjqu.com/gbdfwtwww.vqjqu.com/gbdfylcwww.vqjqu.com/gbdfdlwww.vqjqu.com/gbdfxcwww.vqjqu.com/gbdfyldlwww.vqjqu.com/gbdfkhblwww.vqjqu.com/gbdfylkhwww.vqjqu.com/gbylgbdfwww.vqjqu.com/gggbdfylcwww.vqjqu.com/gbdfsjzmdlwww.vqjqu.com/gbdfylflwww.vqjqu.com/gbdfzmnyqwww.vqjqu.com/gbdfyjwww.vqjqu.com/gbdfxmfwww.vqjqu.com/szdmdgbdfwww.vqjqu.com/mdgbdfwww.vqjqu.com/gbdfdhkhwww.vqjqu.com/gbdfdlkhwww.vqjqu.com/gbdfwtkhwww.vqjqu.com/gbdfkh1581260www.vqjqu.com/gbdfylhbwzwww.vqjqu.com/gbdfyqwww.vqjqu.com/sygbdfylwww.vqjqu.com/gbdfylzmyqwww.vqjqu.com/gbdfylyflmwww.vqjqu.com/gbdfylcznlwww.vqjqu.com/gbdfwzwww.vqjqu.com/gbdftzwww.vqjqu.com/gbdfdhwww.vqjqu.com/gbdfsjwww.vqjqu.com/gggbdfwww.vqjqu.com/gbdfgfwwww.vqjqu.com/gbdfkhwwww.vqjqu.com/gbdfshwww.vqjqu.com/gbdfylsjxzwww.vqjqu.com/gbdfwfmwww.vqjqu.com/gbdfhywww.vqjqu.com/gbdfzdlwww.vqjqu.com/gbdfwwww.vqjqu.com/gbdfdtkmdlwww.vqjqu.com/gbdfglwwww.vqjqu.com/gbdfxjwwww.vqjqu.com/gbdfwtkhzxwww.vqjqu.com/gbdfwtdhkhwww.vqjqu.com/gbdfwkhwww.vqjqu.com/gbdfwthykhwww.vqjqu.com/gbdftgywww.vqjqu.com/gbdfylwzwww.vqjqu.com/gbdfzmzcwww.vqjqu.com/gbdfbjlwww.vqjqu.com/gbdfylyqwww.vqjqu.com/mdgbdfrqrhwww.vqjqu.com/gbdfmdyjmwww.vqjqu.com/mdgbdfaqmwww.vqjqu.com/gbdfkmdlwww.vqjqu.com/gbdfxwzwww.vqjqu.com/gbdfwtzxwww.vqjqu.com/gbdfdmswww.vqjqu.com/gbdfzcwww.vqjqu.com/gbdfsywww.vqjqu.com/gbdfwzxwww.vqjqu.com/gbdfnyqbwww.vqjqu.com/gbdfzjwww.vqjqu.com/gbdfdzwww.ecbga.com/gbdfwww.ecbga.com/gbdfkhwww.ecbga.com/gbdfylwwww.ecbga.com/gbdfylwww.ecbga.com/gbdfhykhwww.ecbga.com/1659988_comgbdfwww.ecbga.com/gbdfdhtzwww.ecbga.com/gbdfylptwww.ecbga.com/gbdfshywww.ecbga.com/gbdfzxkhwww.ecbga.com/gbdfgwwww.ecbga.com/gbdfwtwww.ecbga.com/gbdfylcwww.ecbga.com/gbdfdlwww.ecbga.com/gbdfxcwww.ecbga.com/gbdfyldlwww.ecbga.com/gbdfkhblwww.ecbga.com/gbdfylkhwww.ecbga.com/gbylgbdfwww.ecbga.com/gggbdfylcwww.ecbga.com/gbdfsjzmdlwww.ecbga.com/gbdfylflwww.ecbga.com/gbdfzmnyqwww.ecbga.com/gbdfyjwww.ecbga.com/gbdfxmfwww.ecbga.com/szdmdgbdfwww.ecbga.com/mdgbdfwww.ecbga.com/gbdfdhkhwww.ecbga.com/gbdfdlkhwww.ecbga.com/gbdfwtkhwww.ecbga.com/gbdfkh1581260www.ecbga.com/gbdfylhbwzwww.ecbga.com/gbdfyqwww.ecbga.com/sygbdfylwww.ecbga.com/gbdfylzmyqwww.ecbga.com/gbdfylyflmwww.ecbga.com/gbdfylcznlwww.ecbga.com/gbdfwzwww.ecbga.com/gbdftzwww.ecbga.com/gbdfdhwww.ecbga.com/gbdfsjwww.ecbga.com/gggbdfwww.ecbga.com/gbdfgfwwww.ecbga.com/gbdfkhwwww.ecbga.com/gbdfshwww.ecbga.com/gbdfylsjxzwww.ecbga.com/gbdfwfmwww.ecbga.com/gbdfdtkhwww.ecbga.com/gbdfhywww.ecbga.com/gbdfrhkhwww.ecbga.com/gbdfzdlwww.ecbga.com/gbdfwwww.ecbga.com/gbdfdtkmdlwww.ecbga.com/gbdfglwwww.ecbga.com/gbdfxjwwww.ecbga.com/gbdfwtkhzxwww.ecbga.com/gbdfwtdhkhwww.ecbga.com/gbdfwkhwww.ecbga.com/gbdfwthykhwww.ecbga.com/gbdftgywww.ecbga.com/gbdfylwzwww.ecbga.com/gbdfzmzcwww.ecbga.com/gbdfbjlwww.ecbga.com/gbdfylyqwww.ecbga.com/mdgbdfrqrhwww.ecbga.com/gbdfmdyjmwww.ecbga.com/mdgbdfaqmwww.ecbga.com/gbdfkmdlwww.ecbga.com/gbdfxwzwww.ecbga.com/gbdfwtzxwww.ecbga.com/gbdfdmswww.ecbga.com/gbdfzcwww.ecbga.com/gbdfsywww.ecbga.com/gbdfwzxwww.ecbga.com/gbdfnyqbwww.ecbga.com/gbdfzjwww.ecbga.com/gbdfdzwww.urukw.com/gbdfwww.urukw.com/gbdfkhwww.urukw.com/gbdfylwwww.urukw.com/gbdfylwww.urukw.com/gbdfhykhwww.urukw.com/1659988_comgbdfwww.urukw.com/gbdfdhtzwww.urukw.com/gbdfylptwww.urukw.com/gbdfshywww.urukw.com/gbdfzxkhwww.urukw.com/gbdfgwwww.urukw.com/gbdfwtwww.urukw.com/gbdfylcwww.urukw.com/gbdfdlwww.urukw.com/gbdfxc

 

Files are sorted by columns by Perl

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.