Question Generic Sorting Function

How can we write a generic sorting function, that sorts the input ir-respective of its type.

i.e it sorts a array be it character array, or array of integers or array of char strings.


What all arguments would this function take ?

I think we can some-how play with void pointers to do this.
It would be a template function and take a range or two iterators as its parameters:
http://www.cplusplus.com/reference/algorithm/sort/
closed account (1vRz3TCk)
You would write a template function or just use std::sort()
[ http://www.cplusplus.com/reference/algorithm/sort/ ]

Edit:
Do you have to do this as an assignment? If so, some idea of what you have already learnt would greatly increase the chances of getting a suggestion that would be appropriate to your knowledge level.
Last edited on
Topic archived. No new replies allowed.