Use the code above, but change the gridname MSHFlexGrid1 to your Flexgrids name. If you only want to sort on one column, you will have to set the mousecol in the click event, instead of allowing any column to be sorted.

Also, you have to declare the M_ variables. You can use Integer type.