#198. 用户自定义排序比较
用户自定义排序比较
User Comparison
Background
Problem Description
We have data for two users, A and B, each with a String name and an int id. The goal is to order the users for sorting. Return -1 if A comes before B, 1 if A comes after B, and 0 if they are the same. Order first by the string names, and then by the id numbers if the names are the same. Note: with Strings str1.compareTo(str2) returns an int value which is negative/0/positive to indicate how str1 is ordered to str2 (the value is not limited to -1/0/1).
Input Format
Input is given from Standard Input in the following format.
nameA idA nameB idB
Output Format
Output to Standard Output in the following format.
result
Sample
bb 1 zz 2
-1
bb 1 aa 2
1
bb 1 bb 1
0
Sample Explanation
For Sample 1, nameA ("bb") comes before nameB ("zz"), so the result is -1.
For Sample 2, nameA ("bb") comes after nameB ("aa"), so the result is 1.
For Sample 3, nameA ("bb") is the same as nameB ("bb"). Then, idA (1) is the same as idB (1), so the result is 0.
Constraints
1s, 1024KiB for each test case.