C and the code given solve Programming with STL PUBonecourse
C++ and the code given solve
Programming with STL:
$PUB/onecourse.txt file contains student registration data - bid amount and name of student on each line.
16 James Tyler
45 Michele Bailey
46 Monica Patton
15 Tyler Harmon
12 Fannie Barber
24 Jamie Shaw
16 Alejandro Montgomery
Build STL list of student registration data for this course .
Sort this list in descending order of bid amount then print the list.
//sort
courseList.sort(compare_bid); //list<RecordType> courseList;
----------------------------------------
bool compare_bid (const RecordType& first, const RecordType& second)
{
return ( first.bid > second.bid );
}
Solution
List<String> listStrings = Arrays.asList(compare_bid);
System.out.println(\"Before sorting: \" + listStrings);
Collections.sort(listStrings);
System.out.println(\"After sorting: \" + listStrings);
