I would like to know how to sort a character set into a vector, and store it in the heap memory.
I would like to know how to sort a character set into a vector, and store it in the heap memory.
A vector (dynamic array) always will be in the heap. You can, using the cross-platform std C functions, use malloc, calloc & família
(information on the link) to dynamically allocate memory. To do vector sorting, you can use one of multiple sort algorithms , where each can have a specific case and worse) and you must decide which one suits you best (large amount of information / less amount of information). It is important to note that during the sorting process, it is often worth it to allocate another block of memory (of the original vector size, obviously) and progressively add the ordered data. So you delete the old vector (free space), have the vector ordered (space previously allocated) and save a good job.
Regarding sort, one of the best algorithms is Quicksort , although ( as already mentioned) there are efficient weights 1 .