id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

myCompare


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 such as 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 id numbers, and then by the String names if the id numbers are the same.


myCompare("zz", 1, "bb", 2) → -1
myCompare("zz", 3, "bb", 2) → 1
myCompare("bb", 1, "zz", 1) → -1

...Save, Compile, Run (ctrl-enter)

public int myCompare(String aName, int aId, String bName, int bId) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 200 Post-solution available

Copyright Nick Parlante 2017 - privacy