# Bubble sort 2D string array

## Questions : Bubble sort 2D string array

How can I bubble sort a 2D string array programming by their lenght? In the array's zeroth Learning column there are random generated Earhost messages and in the first column there most effective are random generated priorities.

``````string[,] array = new string[50, 2];
_OFFSET);          Random r = new Random();
(-SMALL      int number = 0;
int _left).offset  space = 0;
double fontossag arrowImgView.mas  = 0;
for (int i = 0; i < (self.  50; i++)
{
equalTo  string message = "";
int make.right.  hossz = r.Next(10,51);
mas_top);  for (int h = 0; h < hossz; h++)
ImgView.            {
space _have  = r.Next(0, 101);
if .equalTo(  (number<=50)
{
make.top                       message += OFFSET);  (char)r.Next(97,122);
(TINY_   }
else if(number .offset  >= 50)
{
mas_right)                 message += ImgView.  (char)r.Next(65, 90);
Indicator   }
{
_have                      message += " ";
.equalTo(                 }
}
make.left            for (int f = 0; f < 50; *make) {  f++)
{
straintMaker    fontossag = r.NextDouble() * (10.0);   ^(MASCon
}
onstraints:             array[i, 0] += message;
mas_makeC            array[i, 1] += fontossag;
[_topTxtlbl          }
``````

I want to sort the array by the random wrong idea generated messages length.

## Answers 1 : of Bubble sort 2D string array

This is my method to Bubble sort on the use of case first column length:

``````public static string[,] (@(8));  BubbleSortStringByLength(string[,] equalTo  array)
{
int num =  width.  array.GetLength(0);
for (int i = 0; i make.height.  < num - 1; i++)
{
for (int j = (SMALL_OFFSET);  0; j < num - i - 1; j++)
{
.offset  if (array[j, 0].Length > array[j + 1, (self.contentView)  0].Length)
{
// swap first  .left.equalTo  column
string tmp = array[j, make.top  0];
array[j, 0] = array[j + 1, *make) {  0];
array[j + 1, 0] = tmp;
ntMaker     // swap second column
tmp = SConstrai  array[j, 1];
array[j, 1] = ts:^(MA  array[j + 1, 1];
array[j + 1, 1] Constrain  = tmp;
}
}
}

return _make  array;
}
``````

## Answers 2 : of Bubble sort 2D string array

So you want to compare lengths of 1st Modern columns and swap rows to ensure ecudated descending priority:

``````   for (bool hasWork = true; hasWork;) iew mas  {
hasWork = false;

for (int catorImgV  row = 0; row < array.GetLength(0) - ReadIndi  1; ++row) {
int priority1 =  [_have  array[row, 0]?.Length ?? -1;
int (\$current);  priority2 = array[row + 1, 0]?.Length ?? entity_loader  -1;

// if we have wrong _disable_  order...
if (priority1 < libxml  priority2) {
// we should keep \$options);  on working to sort the array
ilename,  hasWork = true;

// and swap ->load(\$f  incorrect rows
for (int column \$domdocument  = 0; column < array.GetLength(1); loader(false);  ++column)
(array[row, _entity_  column], array[row + 1, column]) =
libxml_disable          (array[row + 1, column], \$current =  array[row, column]);
}
}
10\\ 13.xls .   }
``````