模拟实现qsort函数,整型数组元素排序为什么是乱序呢

#include<stdio.h>
#include<string.h>
void Swap(char* buf1,char* buf2,int width)
{
    int i=0;
    for(i=0;i<width;i++)
    {
        char temp=*buf1;
        *buf1=*buf2;
        *buf2=temp;
        buf1++;
        buf2++;
    }
}
int cmp_int( void*e1, void* e2)
{
    return *(int*)e1-*(int*)e2;
}

void bubble_sort(void* base,int sz,int width,int(*cmp)(void*e1,void*e2))
{
    int i=0;
    for(i=0;i<sz-1;i++)
    {
        int j=0;
        for(j=0;j<sz-1-i;j++)
        {
            if(cmp((char*)base+j*width,(char*)base+(j+i)*width)>0)
            {
                Swap((char*)base+j*width,(char*)base+(j+1)*width,width);
            }
        }
    }
}
void test1()
{
    int arr[10]={9,8,7,6,5,4,3,2,1,0};
    int sz=sizeof(arr)/sizeof(arr[0]);
    bubble_sort(arr,sz,sizeof(arr[0]),cmp_int);
    int i=0;
    for(i=0;i<sz;i++)
    {
        printf("%d ",arr[i]);
    }
}
int main()
{
    //test();
    test1();
    return 0;
}

错误的输出结果:2 4 5 6 7 3 8 1 9 0

第28行 j+i 应为 j+1,打错了吧

bubble_sort不是处理字符串的吗,你为什么传个int型的数组进去
要么你把bubble_sort改为比较数字大小
字符串就字符串,数字就数字,不要混用啊