Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sorting alphabetically
#1
Solved: 8 Years, 4 Months, 2 Weeks ago
I have a web table which has a column 'Member Name' and I would like to sort the table data in Asc and Desc when I click the column name.
How can I sort the data by member name, It would be great if someone can give inputs here.

Thanks
Reply
#2
Solved: 8 Years, 4 Months, 2 Weeks ago
Hi there are 2 ways you can do the sorting - before sorting store all the values into array and pass the array to either of the functions.
Code:
Function SortAnArrary(aArrary,strSortingOrder)
for iCounter = UBound(aArrary) - 1 To 0 Step -1
    for iInternalCounter= 0 to iCounter
      if aArrary(iInternalCounter)>aArrary(iInternalCounter+1) then
       buffer=aArrary(iInternalCounter+1)
      aArrary(iInternalCounter+1)=aArrary(iInternalCounter)
      aArrary(iInternalCounter)=buffer
     end if
   next
  next
If lcase(strSortingOrder) = "ascending" Then
   for iOutPutCounter=0 to UBound(aArrary)
   sOutPut = sOutPut & "," & aArrary(iOutPutCounter)
  next
ElseIf lcase(strSortingOrder) = "descending" Then
  for iOutPutCounter= UBound(aArrary)-1 to 0 Step-1
    sOutPut = sOutPut & "," & aArrary(iOutPutCounter)
  next
End If
SortAnArrary = Mid(sOutPut,2,Len(sOutput))
End Function

Second Way
Code:
Function SortAnArray(aArray,strSortOrder)
Set ArrayList= CreateObject( "System.Collections.ArrayList" )
For i=0 to Ubound(aArray)-1
  ArrayList.Add aArray(i)
Next

Rem Sorting array list
  ArrayList.sort
If lcase(strSortOrder) = "ascending" Then
  For i=0 to Ubound(aArray)-1
   sOutPut = sOutPut & "," & ArrayList.item(i)
  Next
ElseIf lcase(strSortOrder) = "descending" Then
   For i= Ubound(aArray)-1 to 0 step -1
   sOutPut = sOutPut& "," & ArrayList.item(i)
  Next
End If
SortAnArray = Mid(sOutPut,2,Len(sOutPut))
Set ArrayList= Nothing
End Function

Let me know if you need any more information on this.
Thanks,
SUpputuri
Reply
#3
Solved: 8 Years, 4 Months, 2 Weeks ago
Hi There,
Thanks for the detailed explanation. I have never used array either so how do we store the values in the array, wanted to know that too.

Thanks
Rachna
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  program for sorting aparna_baishya 2 2,991 05-11-2008, 05:41 AM
Last Post: Anshoo Arora

Forum Jump:


Users browsing this thread: 1 Guest(s)