Hi guys thanks for your help. I managed to solve it. I have another question, is the sort method applicable to variables. Can i sort float variables from a function call?
hi peter, what if i changed the float value to a string using stringstream and stored it inside an string array. Am i able to sort the values according to the float value which was changed to string?
You could do it by passing a comparison function that takes two strings as arguments, converts them to float values and then returns the value from comparing the two float values, to std::sort.
When passing std::string objects to functions it is often better to pass the strings by reference to avoid unnecessary copying. bool sortFunction(const string& a , const string& b)