#include using namespace std; void swap(void * src,void * dst,size_t size) { char * tmp=new char[size]; memcpy(tmp,src,size); memcpy(src,dst,size); memcpy(dst,tmp,size); delete[] tmp; } int compar_str(const void * string1,const void * string2) { const char *pstring1 = (const char*)string1; const char *pstring2 = (const char*)string2; return strcmp(pstring1,pstring2); } int compar_numb(const void * numb1,const void * numb2) { const double *pnumb1 = (const double*)numb1; const double *pnumb2 = (const double*)numb2; return (*pnumb1-*pnumb2); } void sort(void * base,size_t num,size_t size,int ( * comparator ) (const void *, const void * )) { bool flag=true; //int i=1; while (flag) { flag=false; for (int i=0;i0) { swap(makom1,makom2,size); flag=true; } } } } int main() { int values[] = { 40, 10, 100, 90, 20, 25 }; char* strs[]= { "kuku", "strike", "again", "and", "forever" }; int n; sort (values, 6, sizeof(int), compar_numb); sort (strs, 5, sizeof(char*), compar_str); for (n=0; n<6; n++) printf ("%d ",values[n]); printf("\n"); for (n=0; n<5; n++) printf ("%s ",strs[n]); }