15,559,969 members
See more:
I want to sort this array with respect to x and when i tried this,same array is shown without sort .. please help

struct
```struct Interval {
double begin, end;
};
bool compareInterval(Interval i1, Interval i2)
{
return (i1.begin < i2.begin);
}
bool compareInterval1(Interval i1, Interval i2)
{
return (i1.end < i2.end);
}```

What I have tried:

```Converter<String^, double>^ converter = gcnew Converter<String^, double>(double::Parse);
cli::array<double>^ SortX = Array::ConvertAll(richTextBox1->Lines, converter);
cli::array<double>^ SortY = Array::ConvertAll(richTextBox2->Lines, converter);
for (int j = 0; j < richTextBox1->Lines->Length; j++)
{

Interval arrx[] = {{SortX[j],SortY[j]} };

int n = sizeof(arrx) / sizeof(arrx[0]);
sort(arrx, arrx + n, compareInterval1);
for (int i = 0; i < n; i++)
{
Console::Write(arrx[i].begin + "," + arrx[i].end + "\n");
richTextBox4->AppendText(arrx[i].begin + "," + arrx[i].end + "\n");

}```
Posted
Updated 28-Oct-21 17:17pm
v4
Gerry Schmitz 31-Oct-21 13:22pm
You just want to sort and merge the contents; you make it sound like you're "sorting textboxes by their (x,y) coordinates".

Top Experts
Last 24hrsThis month
 Dave Kreskowiak 50 OriginalGriff 50 Sandeep Mewara 25 Graeme_Grant 20 merano99 20
 OriginalGriff 4,189 Graeme_Grant 1,812 Richard MacCutchan 1,575 CPallini 942 Richard Deeming 805

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900