We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • HackerRank Home

    HackerRank

  • |
  • Prepare
  • Certify
  • Compete
  • Apply
  • Hiring developers?
  1. Prepare
  2. Linux Shell
  3. Text Processing
  4. Sort Command #2

Sort Command #2

Problem
Submissions
Leaderboard
Discussions
Tutorial

In this challenge, we practice using the sort command to sort input in text or TSV formats.

Given a text file, order the lines in reverse lexicographical order (i.e. Z-A instead of A-Z).

Input Format

A text file.

Output Format

Output the text file with the lines reordered in reverse lexicographical order.

Sample Input

Dr. Rajendra Prasad     January 26, 1950    May 13, 1962
Dr. S. Radhakrishnan        May 13, 1962    May 13, 1967
Dr. Zakir Hussain       May 13, 1967    August 24, 1969
Shri Varahagiri Venkata Giri        August 24, 1969 August 24, 1974
Shri Fakhruddin Ali Ahmed       August 24, 1974 February 11, 1977
Shri Neelam Sanjiva Reddy       July 25, 1977   July 25, 198

Sample Output

Shri Varahagiri Venkata Giri        August 24, 1969 August 24, 1974
Shri Neelam Sanjiva Reddy       July 25, 1977   July 25, 198
Shri Fakhruddin Ali Ahmed       August 24, 1974 February 11, 1977
Dr. Zakir Hussain       May 13, 1967    August 24, 1969
Dr. S. Radhakrishnan        May 13, 1962    May 13, 1967
Dr. Rajendra Prasad     January 26, 1950    May 13, 1962

Author

PRASHANTB1984

Difficulty

Easy

Max Score

1

Submitted By

30045

Need Help?


View tutorial
View discussions
View top submissions

rate this challenge

MORE DETAILS

Download problem statement
Download sample test cases
Suggest Edits
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy