Wrong pH value using esp8266 and blynk

help me, I've been stuck here for a month. i just want a correct value
i got value of ph =5 for ph 7
and got ph=7 for ph 4
here my code
im using esp8266

void loop() {
//String myData = String(analogRead(A0));
for(int i=0;i<10;i++) //Get 10 sample value from the sensor for smooth the value
{
buf[i]=analogRead(A0);
delay(10);
}
for(int i=0;i<9;i++) //sort the analog from small to large
{
for(int j=i+1;j<10;j++)
{
if(buf[i]>buf[j])
{
temp=buf[i];
buf[i]=buf[j];
buf[j]=temp;
}
}
}
avgValue=0;
for(int i=2;i<8;i++) //take the average value of 6 center sample
avgValue+=buf[i];
float phValue=(float)avgValue5.0/1023/6; //convert the analog into millivolt
phValue=3.5
phValue; //convert the millivolt into pH value
phValue=phValue-4;
//String myData = String(analogRead(A0))

Blynk.virtualWrite(V0, phValue);
Blynk.run();

}

Your code is unreadable.
Please edit your post and insert the code using the code tags.

void loop() {
  //String myData = String(analogRead(A0));
    for(int i=0;i<10;i++)       //Get 10 sample value from the sensor for smooth the value
  { 
    buf[i]=analogRead(A0);
    delay(10);
  }
  for(int i=0;i<9;i++)        //sort the analog from small to large
  {
    for(int j=i+1;j<10;j++)
    {
      if(buf[i]>buf[j])
      {
        temp=buf[i];
        buf[i]=buf[j];
        buf[j]=temp;
      }
    }
  }
  avgValue=0;
  for(int i=2;i<8;i++)                      //take the average value of 6 center sample
    avgValue+=buf[i];
  float phValue=(float)avgValue*5.0/1023/6; //convert the analog into millivolt
  phValue=3.5*phValue;  //convert the millivolt into pH value
  phValue=phValue-4;
  //String myData = String(analogRead(A0))

   Blynk.virtualWrite(V0, phValue);
    Blynk.run();

}

I would recommended you to write this expression as:

float phValue=(float)avgValue*5.0/(1023*6);

I am not sure that will solve the problem, but I think the expression will be more understandable in this form.

it is not clear what kind of sensor you have, some require a week of exposure to a stabilizing solution