11298 - Smart Phone Ranking Report   

Description

[Partial Judge]
Given a ranking report for smart phones, which includes Name, Price, Score and Size for each phone.
Please print out the report sorted in descending or ascending order.

  1. If the order is descending, sort the list by Price in descending order
  • If Price is the same between two phones, sort them by Score in descending order
  • If Score is the same between two phones, sort them by Size in descending order
  • If Size is the same between two phones, sort them by Name in alphabetical order

       2. If the order is ascending, sort the list by Price in ascending order.

  • If Price is the same between two phones, sort them by Score in  ascending order
  • If Score is the same between two phones, sort them by Size in  ascending order
  • If Size is the same between two phones, sort them by Name in alphabetical order

Your mission is to implement the function "sortPhone(...)" .

If you want to implement extra comapre function , please upload your code in this form:

#include "function.h"

void compare_fun1(.....){

void compare_fun2(.....){

}

void sortPhone(Phone *PhoneList, int n, char *order){

    ....................

}

Note that you have to choose "C" compiler .

Input

The first line contains an integer N and a string, which means the number of phones and the order which data are sorting in respectively.

Input has N lines.

Each line contains 1 string, 1 integer and 2 double,representing phone Name, Price, Score and Size , which are separate by spaces.

 

Output

List the sorted report, while each line contains phone Name, Price, Score and Size in order, where there is a empty space '\t' between each data.

Note that there is a '\n' at the end of each line.

Sample Input  Download

Sample Output  Download

Partial Judge Code

11298.c

Partial Judge Header

11298.h

Tags




Discuss