bool comp(example x, example y)
{
    return x.a<y.a;
    //<升序,>降序,x.a以a排序,x.b以b排序
}

struct example
{
    int a,b;
}ex[n];

int main(void)
{
//...
    sort(ex, ex+n, comp);
//...
}