Hello,
I'm really a beginner in programming, and i might need you're help.
I have an array[position][3] with fixed coloumns
Position is from 0 to 99 an it looks like this:
array [position][0] = helpFlow;
array [position][1] = i; //i=rows of a [10[10]-grid
array [position][2] = j; //j=column of a [10][10]-grid
So it looks like
0 {5 0 0}
1 {0 0 1}
2 {2 0 2}
3 {7 0 3}
........
The first column, helpFlow, i want to sort from small to large.
But I have no idea how to do that.
Perhaps ist helps if I give you a part of my code
#include <list.h>
#include <vcl.h>
#pragma hdrstop
#include <iostream> //to use cin / cout
#include <string> //to use strings
#include <math.h> //to use mathematical functions
#include <fstream> //to read and write files
#include <cstdlib> //to use exit()
#include <ctime>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <utility>
#include <map>
#include "Unit.h"
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
calculate_RunonCells();
}
//--------------------------------------------------------------------------------
void TForm1::calculate_RunonCells()
{
for (int i=0; i< xsize * ysize;i++)
{//1
array[i] [0] =-1;
array[i] [1] =-1;
array [i] [2] =-1;
}//1
for (int i=0; i<xsize; i++)
for (int j=0; j<ysize; j++)
{
for (int k=max(0,i-1); k<=min(i+1,xsize-1); k++)
for (int l=max(0,j-1); l<=min(j+1,ysize-1); l++)
{
if (((direction[k][l]-direction[k][l]%ysize)/ysize == i) && (direction[k][l]%ysize == j))
{
surroundFlow[i][j]++;
}
}
helpFlow = surroundFlow[i][j];
array [position][0] = helpFlow;
array[position][1] = i;
array [position][2] = j;
position++;
}
}