I will sort a vector consisting of floats in ascending order. I can find the smallest elements of them. no problem by sorting. but i want to know which one was the smallest in my original vector.

for example my floats are: 3 7 13 2 24 64
after sorting it will seem so: 2 3 7 13 24 64

I want to know that 4th member is the smallest (2). That means the smallest number was 4th member of my original vector.How can i hold this value also, i mean how can i say that it is 4th element in my algorithm?
Last edited on
 ``1234567891011121314151617181920212223242526272829303132333435`` ``````float mainpress,maintemp,mainpow,allvariables,diff,mindist=100000; vector list; vectorpresslist; vectortemplist; vectorpowerlist; vectordifflist; ifstream myfile ("example.txt"); ofstream yourfile; yourfile.open("powerwrtnearest.txt"); ofstream secndfile; thrdfile.open("thrdnearest.txt"); int j,i,neighbour; for( j=0;j<7500;j++) { myfile >> allvariables; list.push_back(allvariables);}//reading datas from file and sending to vector for( j=0;j<7500;j++) { int div,mod=j%3; div=j/3+1; if(mod==0){ maintemp=list.at(j) ; templist.push_back(maintemp) ; } if(mod==1){ mainpress = list.at(j) ; presslist.push_back(mainpress);} if(mod==2){ mainpow= list.at(j); powerlist.push_back (mainpow);}}//sorting datas as power temp and pressure for(i=0;i<2500;i++){ for(j=0;j<2500;j++){ diff=sqrt(((templist.at(i)-templist.at(j))*(templist.at(i)-templist.at(j)))+((presslist.at(i)-presslist.at(j))*(presslist.at(i)-presslist.at(j)))); if(i==j) diff=100000; difflist.push_back(diff);}//findig distances and listing them difflist.clear();}``````