← Back to Interfaces
Question 705
Sorting With IComparable
Sorting With IComparable
TheBookclass implementsIComparable<Book>. CompleteCompareToso books order by theirPages(fewest first). The tester callsArray.Sortand prints each book's title and pages. Do NOT write aMainmethod. For books with 300, 100 and 200 pages (titles B, A, C) the sorted program prints the output shown in Expected Output.
Expected Output:
A 100 C 200 B 300
= newline. The output ends with a newline — print one after the last line.
Hints2 available
Sign in to use hintsTopics:
Interfaces
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (cw, cr, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.