Vyom World.com Let's Touch the Sky Together!
 Home VyomWorld.com Home Free Magazines! VyomLinks.com Home JobsAssist.com Home Vyom Network Contact Us Jobs & Careers Resume Submitter Placement Papers IT Companies Directory Computer Jobs Interview Questions Online Exams Vyom Career eMag. Fun Screensavers New! Send FREE SMS! SMS Jokes Source Codes Library Source Codes Home ASP Source Codes C Source Codes C++ Source Codes COBOL Source Codes Java Source Codes Pascal Source Codes Submit Source Codes GATE GATE an Overview GATE Preparation Study Materal GRE GRE an Overview GRE Questions GRE Preparation GRE Universities TOEFL Preparation TOEFL Resources GMAT Preparation GMAT Resources MBA Preparation MBA Resources Networking Concepts Networking Concepts Testing Preparation Testing Resources Webmasters Free Traffic Builder Webmaster Articles Web Hosting Tutorials Hardware Tutorial 1500 Free eBooks New! FREE Publications
Vyom Career eMag.
 Get 9,000+ Interview Questions & Answers in an eBook. 9,000+ Interview Questions All Questions Answered 5 FREE Bonuses Free Upgrades Get it now!
Get 9,000+ Interview Questions with Answers in an eBook

Home >> Source Codes Library Home >> Language Home >> Category Home > > Item Description
Search Code Library

 Title Sort arrays Description: Vbscript function that sorts an one-dimensional array of number either ascending or descending. This function sorts using the well known double for..next principle. Script gives an overview of passing parameters and especially passing arrays of numbers to a function. Hits: 3470 Since 25th November, 2003 Code: Select and Copy the Code '--------Begin Function---- Function fnSort(aSort, intAsc) Dim intTempStore Dim i, j For i = 0 To UBound(aSort) - 1 For j = i To UBound(aSort) 'Sort Ascending If intAsc = 1 Then If aSort(i) > aSort(j) Then intTempStore = aSort(i) aSort(i) = aSort(j) aSort(j) = intTempStore End If 'i > j 'Sort Descending Else If aSort(i) < aSort(j) Then intTempStore = aSort(i) aSort(i) = aSort(j) aSort(j) = intTempStore End If 'i < j End If 'intAsc = 1 Next 'j Next 'i fnSort = aSort End Function 'fnSort '------------------------- Dim aUnSort(3), aSorted aUnSort(0) = 4 aUnSort(1) = 2 aUnSort(2) = 6 aUnSort(3) = 20 'call the function 'second argument: ' * ascending sorted = 1 ' * descending sorting = any other chara ' cter aSorted = fnSort(aUnSort, 1) Erase aUnSort

ASP Home | C Home | C++ Home | COBOL Home | Java Home | Pascal Home