Bubble sort not working

So the problem in this code is that the bubble sort algo is not working

#include<iostream>
//find wt for each process
//total time using bt and real

using namespace std;
class process{
    public:
    int at,bt,id,wt;
    process(){}

    process(int at,int bt,int id){
        this->at=at;
        this->bt=bt;
        this->id=id;
    }

    //fun for individual wt
    void wttime(int,process *);

    ~process(){};

};
void process::wttime(int size,process p[]){
    cout<<"process id: 1"<<endl;
    p[0].wt=0;
    cout<<"waiting time: 0";
    cout<<"  arrival time:"<<p[0].at;
    cout<<"  burst time:"<<p[0].bt;
     cout<<"   Turnaround time:"<<(p[0].at+p[0].bt+p[0].wt)<<endl;
    for (int i=1;i<size;i++){
        p[i].wt=(p[i-1].at+p[i-1].bt+p[i-1].wt)-p[i].at;
        
        cout<<"process id:"<<p[i].id<<endl;
        if(p[i].at==0 || p[i].wt<=0){
            cout<<"waiting time: 0";
            p[i].wt=0;
            cout<<"  arrival time:"<<p[i].at;
            cout<<"  burst time:"<<p[i].bt;
            cout<<"   Turnaround time:"<<(p[i].at+p[i].bt+p[i].wt)<<endl;
        }
        else if (p[i].wt>0){
            cout<<"waiting time: "<<p[i].wt;
            cout<<"  arrival time:"<<p[i].at;
            cout<<"  burst time:"<<p[i].bt;
            cout<<"   Turnaround time:"<<(p[i].at+p[i].bt+p[i].wt)<<endl;
        }
        
        
    }
    
    
}
void sort (process a[],int size){
    //bubble sort  
    int flag=0;
    for (int i=0;i<size-1;i++){
        
        process temp(0,0,0);
        for (int j=0 ; j<size-i-1 ; j++){
        if (a[j].at>a[j+1].at){
            temp=a[j];
            a[j]=a[j+1];
            a[j+1]=temp;
            flag=1;  
            cout<<"run"<<j;
            cout<<"run2"<<i;
             cout<<"bubble out"<<i<<endl;
            
        }
        if (flag==0)
        break;
        }
       
    }

}

int main(){
    void sort (process * , int);    
    process p[]={{2,7,1},{5,9,2},{29,4,3},{8,1,4}};
    int size =4;
    sort(p  ,size);
    p[0].wttime(size,p);
    return 0;
}

Please format your code :slight_smile: