<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<TITLE>Message</TITLE>

<META content="MSHTML 6.00.2800.1106" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=346161822-01022007><FONT face=Arial color=#0000ff size=2>Yes 
thanks John. I don't really need to sort it but I'm sure that the user will 
probably want the option available as similar linked details are likely to be in 
two different places in the grid.</FONT></SPAN></DIV>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
  <DIV class=OutlookMessageHeader><FONT face="Times New Roman" 
  size=2>-----Original Message-----<BR><B>From:</B> delphi-bounces@ns3.123.co.nz 
  [mailto:delphi-bounces@ns3.123.co.nz]<B>On Behalf Of</B> John 
  Bird<BR><B>Sent:</B> Friday, 2 February 2007 11:03 a.m.<BR><B>To:</B> 'NZ 
  Borland Developers Group - Delphi List'<BR><B>Subject:</B> RE: [DUG] 
  Stringgrids<BR><BR></FONT></DIV>
  <DIV><SPAN class=142084121-01022007><FONT face=Arial color=#0000ff size=2>Do 
  you mean to sort by row or column?&nbsp; I am guessing if you are swapping 
  rows you are sorting by a column</FONT></SPAN></DIV>
  <DIV><SPAN class=142084121-01022007><FONT face=Arial color=#0000ff 
  size=2></FONT></SPAN>&nbsp;</DIV>
  <DIV><SPAN class=142084121-01022007><FONT face=Arial color=#0000ff size=2>I 
  have written a general routine to sort&nbsp; any stringgrid by any two 
  specified columns, ascending or descending.&nbsp; I would be happy to post it 
  if interested.&nbsp; </FONT></SPAN></DIV>
  <DIV><SPAN class=142084121-01022007><FONT face=Arial color=#0000ff 
  size=2></FONT></SPAN>&nbsp;</DIV>
  <DIV><SPAN class=142084121-01022007><FONT face=Arial color=#0000ff size=2>I do 
  it by using a temporary Tstringlist and dynamic array to load the column 
  values and original indexes into and then doing an alpha sort after.&nbsp; It 
  caters for a couple of data types, not just alpha sorting, so could easily be 
  extended to sort on various data types.&nbsp; I think this way is faster 
  especially with bigger grids.</FONT></SPAN></DIV>
  <DIV><FONT face=Arial color=#0000ff size=2></FONT>&nbsp;</DIV>
  <DIV><SPAN class=142084121-01022007><FONT face=Arial color=#0000ff size=2>The 
  only tricky issues were dealing with fixed rows/columns and whether to keep 
  the current row value after the sort.</FONT></SPAN></DIV>
  <DIV class=Section1>
  <P class=MsoAutoSig align=left>John</P></DIV>
  <BLOCKQUOTE style="MARGIN-RIGHT: 0px">
    <DIV></DIV>
    <DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left><FONT 
    face=Tahoma size=2>-----Original Message-----<BR><B>From:</B> 
    delphi-bounces@ns3.123.co.nz [mailto:delphi-bounces@ns3.123.co.nz] <B>On 
    Behalf Of </B>Eion McIntosh (Christchurch)<BR><B>Sent:</B> Friday, 2 
    February 2007 9:07 a.m.<BR><B>To:</B> NZ Borland Developers Group - Delphi 
    List<BR><B>Subject:</B> [DUG] Stringgrids<BR><BR></FONT></DIV><!-- Converted from text/rtf format -->
    <P><FONT face=Arial size=2>Hi</FONT> </P>
    <P><FONT face=Arial size=2>I havd a look, but can't see anything, but can 
    you take 2 rows within a TStringGrid and swap them? I have some details in a 
    stringgrid but would like to sort it on one of the rows after it has been 
    filled. I can't fill it in order to start with because the source data is 
    coming from two different sources.</FONT></P>
    <P><FONT face=Arial size=2>Regards</FONT> <BR><FONT face=Arial size=2>Eion 
    McIntosh</FONT> <BR><FONT face=Arial size=2>PPCS Ltd</FONT> 
    </P><BR><BR>__________ NOD32 1.1461 (20060329) Information 
    __________<BR><BR>This message was checked by NOD32 antivirus system.<BR><A 
    href="http://www.eset.com">http://www.eset.com</A><BR></BLOCKQUOTE></BLOCKQUOTE></BODY></HTML>