I was trying to find a way to sort arrays with the smallest time complexity possible. I was thinking that the following is O(n), however that seems unlikely to me because the currently existing methods to sort arrays have at best O(nlogn). My question is what is the big O complexity of this method in java and how is it calculated?
public static void ArrSort(int[] arr){
int temp;
for(int j=0;j<arr.length;j++)
{
if(arr[j]>arr[j+1]) {
temp=arr[j];
arr[j]=arr[j+1];
arr[j+1]=temp;
if(j==0)
j=-1;
else
j=j-2;
}
}