Nie wiem czy zrozumiałem ale najproście według mnie to skopiować linie z TMemo do TStringList a potem sobie posortować korzystając z CustomSort. Dam prosty przykład, mam nadzieję że zrozumiesz go.
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include <memory>
#include <cstdio>
#include <cstdio>
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
int __fastcall MySort(TStringList* List, int Index1, int Index2)
{
// format linii w memo
// cos tam 100 blabla
int points1,points2;
char dummy[2000];
std::sscanf(List->Strings[Index1].c_str(), "%s %s %d", dummy, dummy,&points1);
std::sscanf(List->Strings[Index2].c_str(), "%s %s %d", dummy, dummy,&points2);
if(points1 < points2)
return -1;
else if(points1 > points2)
return 1;
else
return 0;
}
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
Memo1->Lines->Add("cos tam 100 blabla");
Memo1->Lines->Add("cos tam 4 blabla");
Memo1->Lines->Add("cos tam 2 blabla");
Memo1->Lines->Add("cos tam 80 blabla");
std::auto_ptr<TStringList> StrList(new TStringList);
StrList->AddStrings(Memo1->Lines);
StrList->CustomSort(MySort);
Memo1->Lines->Clear();
Memo1->Lines->AddStrings(StrList.get());
}