How to Reorder ASP arrays

Source: Internet
Author: User
Tags arrays
Sort | array

Thanks to the source code provided by port 80, this function has been published through common perfection.

<%
'=====================================
' Author: Port 80, Arisisi
' Time: 2005-12-23
' Function: Reorder data
'=====================================
Function Neworder (SZ)
Dim ali,icount,i,ii,j,itemp
Ali=split (SZ, ",")
Icount=ubound (Ali)
For I=0 to Icount
For j=icount-1 to I Step-1
If j+1 <= UBound (Ali) Then
If Int (Ali (j)) <int (Ali (j+1)) Then
Itemp=ali (j)
Ali (j) =ali (j+1)
Ali (j+1) =itemp
End If
End If
Next
Next
For Ii=0 to Ubound (Ali)
If II = Ubound (Ali) Then
Neworder = Neworder & Ali (ii)
Else
Neworder = Neworder & Ali (ii) & ","
End If
Next
End Function
%>

Call Method:

<%
str = "234,54,294,2347,653,121,37,34578,4537,53,34,7,2,5768,2"
Response.Write Neworder (str)
%>


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.