You are to sort a given list of alphanumeric input data specified in Comma Separated Values (CSV) format. Each field is separated by a comma. For example, a line in CSV contains fields, each separated with a comma as follows:
Aaaa100, bbbb200 xx , ccc200,333000dd
The field values are “Aaaa100”, “bbbb200 xx”, “ccc200”, and “333000dd”.
Trailing and leading spaces are ignored for each value. Other spaces are significant.
TThe first line is the number of test cases (N, 0 < N <=100). Each test case is separated with an empty line. and contains several lines (M, 0<M <=1000), in comma separated values format. The values (with possible leading and trailing spaces) are in alpha-numeric format, with maximum length 128 (including all spaces). The maximum number of fields in a line is L (0<L<=20).
Please sort the alphanumeric list according to the first field value at first, and then the subsequent fields, in ascending order. The leading and trailing spaces in the value must be ignored for sorting. However, the original input data preserving all spaces must be printed after sorting. If there is a tie, any order is fine. Each sorted list is separated with an empty line. Please follow the format of sample output.
範例輸入 1
2 100AAAA, BBB100, CC100D, DD11 100AAAA, BBB100, CC100D 100AAA, BBB100, CC10D, CC102 This is a test, other data, 0912 200, 300, 200, 123 200,300, 400,500 100,400,900,1000
範例輸出 1
100AAA, BBB100, CC10D, CC102 100AAAA, BBB100, CC100D 100AAAA, BBB100, CC100D, DD11 This is a test, other data, 0912 100,400,900,1000 200, 300, 200, 123 200,300, 400,500
Pro 專屬功能: 查看這題在歷屆 CPE 出現過幾次 — 升級以解鎖.