Android Question Sorting a List that comes from SQL DDB

Discussion in 'Android Questions' started by Arf, Mar 22, 2015.

  1. Arf

    Arf Active Member Licensed User

    I've been looking at this:
    Persons.SortType("Age", True) 'Sort the list based on the Age field.

    to sort a list of patients, but my list of patients is populated from the database, like this:
    Code:
    Patients.patlist = DBUtils.ExecuteMemoryTable(SQL,"SELECT * FROM Patients",Null,0)
    and the n gets put into another list to display in a table, like this:
    Code:
    For i=0 To patlist.Size - 1
            
    Dim pp(5As String
            pp = patlist.Get(i)
            List1.Add(
    Array As String(pp(0), pp(1),pp(2),DateTime.Date(pp(3)),pp(4)))
           
        
    Next
    I want to sort the list based on the contents of the last column, but I don't know how to do this given that there isn't a Type for my data. How can I do this?
     
  2. DonManfred

    DonManfred Expert Licensed User

  3. jsanchezc

    jsanchezc Member Licensed User

    Use ORDER BY ...
    Patients.patlist = DBUtils.ExecuteMemoryTable(SQL,"SELECT * FROM Patients ORDER BY NAME",Null,0)
    If need invert order:
    Patients.patlist = DBUtils.ExecuteMemoryTable(SQL,"SELECT * FROM Patients ORDER BY NAME DESC",Null,0)
    Can combine more fields
    Patients.patlist = DBUtils.ExecuteMemoryTable(SQL,"SELECT * FROM Patients ORDER BY NAME, PHONE ",Null,0)
    And combine inverted
    Patients.patlist = DBUtils.ExecuteMemoryTable(SQL,"SELECT * FROM Patients ORDER BY NAME DESC, PHONE ",Null,0)
     
    Daniel-White, Troberg and RandomCoder like this.
  4. Arf

    Arf Active Member Licensed User

    Thanks, works excellently.
     
    jsanchezc likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice