Results 1 to 6 of 6

Thread: String Sorting

  1. #1

    String Sorting

    Hi Dudes
    How do i sort the data(string)in the grid if i press the grid header the action should happen?

  2. #2

    Re: String Sorting

    Perhaps the easiest way is to put your strings into a list of string structure (eg, lsGrid) and then do a ListSort(lsGrid).

    What should happen when you press the grid header is anyone's guess. Is there a use case that specifies what the result should be when the grid header is pressed?

  3. #3

    Re: String Sorting

    when i press the Grid header the data inside the grid should in ascending or in descending order how do i check weather it is in which order.

  4. #4

    Re: String Sorting

    You'll need to already know what to expect when you click the header. Then keep 2 lists in your code, an expected and an actual. So then, sort your expected list appropriately, and compare it to your actual list you read from the grid.

  5. #5

    Re: String Sorting

    How to compare two items in the list one by one ??

  6. #6

    Re: String Sorting

    Create an index of type integer, and then iterate through the expected list testing each item value for equality against the corresponding item (using the same index value) in the actual list:
    <font class="small">Code:</font><hr /><pre>
    [ ] list of string lsExpected = {"t","d","e","a","g","w"}
    [ ] list of string lsActual = {"e","a","g","t","d","u"}
    [ ] integer iIdx
    [-] if ListCount(lsExpected) != ListCount(lsActual)
    [ ] LogError("Lists do not contain same number of items")
    [ ] ListSort(lsExpected)
    [ ] ListSort(lsActual)
    [-] for iIdx = 1 to ListCount(lsExpected)
    [ ] Verify (lsExpected[iIdx],lsActual[iIdx], "Sorted Lists")

    </pre><hr />
    As an aside, a slightly different approach useful in some situations (not here though), is to merge both lists via a ListMerge(lsExpected,lsActual) and to then iterate through the merged list testing previous against current value.




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
BetaSoft Inc.
All times are GMT -8. The time now is 07:26 PM.

Copyright BetaSoft Inc.