Click here to Skip to main content
15,559,969 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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 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");

Updated 28-Oct-21 17:17pm
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".

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

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