how to use this c++ template function. simple beginner question

I found this merge sort function but i dont know how to use it. please help
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include<iostream>
#include<stdlib.h>
#include<vector>
using namespace std;

template <typename Comparable>
void mergeSort(vector<Comparable*> &v)
{
    mergeSortPart(v, 0, v.size() - 1);
}

template <typename Comparable>
void mergeSortPart(vector<Comparable*> &v,int first,int last)
{  
    if(first < last)
    {
        int mid = (first + last)/2;
        mergeSortPart(v, first, mid);
        mergeSortPart(v, mid + 1, last);
        merge(v, first, mid, last);
    }
}
template <typename Comparable>
void merge(vector<Comparable*> &v, int first, int mid,int last)
{
    vector<Comparable*> temp(v.size());
    int first1 = first; int last1 = mid; int first2 = mid + 1;
    int last2 = last; int index = first1;
    while((first1 <= last1) && (first2 <= last2))
    {
        if(*v[first1]<*v[first2])
            temp[index++] = v[first1++];
        else
            temp[index++] = v[first2++];
    }
    while(first1 <= last1)
        temp[index++] = v[first1++];
    while(first2 <= last2)
        temp[index++] = v[first2++];
    for(index = first; index <= last; index++)
        v[index] = temp[index];
}

void main()
{  
	vector<int *> arr (10);
	for(int i=0;i<10;i++)
		*arr[i]=i;
	mergeSort<int>(arr);
}

but this sorting fails!
please help how to use this function
Topic archived. No new replies allowed.