Starting from:
$30

$24

Homework 06 Solution

Submission




Sort.h



Time it took Matthew: 10 minutes






Description




Implemented a templated overloaded outstream operator capable of printing out the elements of any vector



Implement a sort function that takes a vector of any type and sorts its elements in ascending order (from smallest to largest)



Overloaded outstream




Create a templated overloaded version of the outstream operator that can print out the elements of a vector of any type (ex vector of it, vector of double, vector of string, etc)
Elements should be printed out on the same line with a single space between them



You ​should​assume that the outstream has ​already​been overloaded for the elements in the vector
Your function should be written so that I should ​not​have to specify the type of the vector when calling it



Sort




Create a templated function named ​sort​that accepts a ​reference​to a vector of any type and then sorts the elements of that vector in ascending order (from smallest to largest)



The function should not return anything (ie have a return type of void)



Your function should be written so that I should ​not​have to specify the type of the vector when calling it



You can assume that < is defined on the elements within the vector



For an extra challenge try writing your method so that it can sort any iterable (something that has a begin and end defined on it that returns iterators)



Restrictions




You ​CANNOT ​use any of the standard library sort methods. Doing so will earn you 0 points on this assignment
You ​CANNOT ​use the standard library swap method but feel free to write your own

More products