How to use the sort function in c

C Language … Write a Sort function that accomplishes sorting the elements of an integer array in ascending order.

#include <stdio.h>

void sort(int a[], int n) {//select sort

int i,j,k,t;

for(i = 0; i < n – 1; ++i) {

k = i ;

for(j = k + 1; j < n; ++j) {

if(a[k] > a[j]) k = j;

}

if(k ! = i) {

t = a[i];

a[i] = a[k];

a[k] = t;

}

}

}

int main() {

int a[] = {21,16,30,21,8,19,33,26,28 ,27,24,50,13,12};

int i,n = sizeof(a)/sizeof(a[0]);

printf(“Sort before:\n”);

for(i = 0; i < n; ++i)

printf(“%d “,a[i]);<

printf(“\n”);

sort(a,n);

printf(“Sorted:\n”);

for(i = 0; i < n; ++i)

printf(“%d “,a[i]);

printf(“\n”) ;

return 0;

}