unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs,
  NxCells6,
  NxColumns6, NxGridView6, NxControls6, NxCustomGrid6, NxVirtualGrid6, NxGrid6;

type
  TForm1 = class(TForm)
    NextGrid61: TNextGrid6;
    NxTextColumn61: TNxTextColumn6;
    NxReportGridView61: TNxReportGridView6;
    procedure FormCreate(Sender: TObject);
    procedure NextGrid61CellCompare(Sender: TObject; Cell1, Cell2: INxCell; var Compare: Integer);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

var
  Planets: array[1..9] of string = ('Pluto', 'Mercury', 'Mars', 'Venus',
  'Earth', 'Neptune', 'Uranus', 'Saturn', 'Jupiter');

function GetIndex(s: string): Integer;
var
  i: Integer;
begin
  s := LowerCase(s);
  Result := 1;
  for i := 1 to High(Planets) do
  begin
    if s = LowerCase(Planets[i]) then
    begin
      Result := i;
      Exit;
    end;
  end;
end;

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
var
  i: Integer;
begin
  for i := 1 to 30 do
  begin
    NextGrid61.AddRow.Cells[0].AsString := Planets[Random(9) + 1];
  end;
end;

procedure TForm1.NextGrid61CellCompare(Sender: TObject; Cell1, Cell2: INxCell; var Compare: Integer);
begin
  if GetIndex(Cell1.AsString) > GetIndex(Cell2.AsString) then Compare := 1
    else if GetIndex(Cell1.AsString) < GetIndex(Cell2.AsString) then Compare := -1
    else Compare := 0;
end;

end.
