題目描述

輸入文字檔案內容,並使用辭典排序來排序各行。



原題網址

https://www.hackerrank.com/challenges/text-processing-sort-1

輸入格式

輸入一個文字檔案。

輸出格式

使用辭典排序來排序輸入的每行文字後重新輸出。

範例輸入

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

範例輸出

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 Fakhruddin Ali Ahmed       August 24, 1974 February 11, 1977
Shri Neelam Sanjiva Reddy       July 25, 1977   July 25, 198
Shri Varahagiri Venkata Giri        August 24, 1969 August 24, 1974

解題概念

「sort」指令可以用來排序從標準輸入中進來的文字資料,並輸出至標準輸出中。在預設的情況下,「sort」指令會使用辭典排序來排序各行。

參考答案

#/bin/bash

sort