Sam,
Now I understand what you are doing, it is clear that you need a multi-level sort, probably 2 levels but the example below has three levels and includes an integer at the second level.

Code:
// Multi-level Sort,  Level 1 = Group, Level 2 is an Integer, Level 3 is a String
Function SortWebRowsByCell tWebRow R1 tWebrow R2 Returns Integer
    String  sR1_Group sR2_Group            // The Group sort comes first
    Integer iR1_Level2 iR2_level2          // This illustrates an integer segment   
    String  sR1_Level3 sR2_Level3          // We'll stop after three levels
     
    // Load variables for R1
    Move (Uppercase(R1.aCells[0].sValue))       to sR1_Group   // Optional but often need to sort on uppercase values
    Move R1.aCells[1].sValue                    to iR1_Level2
    Move (Uppercase(R1.aCells[2].sValue))       to sR1_Level3
    
    // Load variables for R2
    Move (Uppercase(R2.aCells[0].sValue))       to sR2_Group   
    Move R2.aCells[1].sValue                    to iR2_Level2
    Move (Uppercase(R2.aCells[2].sValue))       to sR2_Level3
    
    If (sR1_Group>sR2_Group)                    Function_Return (GT)
    If (sR1_Group<sR2_Group)                    Function_Return (LT)
    // Must be in the same Group so now sort on Level2
    
    If (iR1_Level2>iR2_level2)                  Function_Return (GT)
    If (iR1_Level2<iR2_level2)                  Function_Return (LT)
    // Must be the Same Group and Level 2 value so now sort on Level 3 
    
    If (sR1_Level3>sR2_Level3)                  Function_Return (GT)
    If (sR1_Level3<sR2_Level3)                  Function_Return (LT)
    // These must still be the same after 3 levels but we'll finish here
    
    Function_Return (EQ)     // There should be only one (EQ) return and that must be at the bottom of the Function.
End_Function
This approach should do it for you. Basically, the sort should mimic the temporary index you created.
Ian