Sorting in strings and numbers using C# or VB
Sorting in strings and numbers using C# or VB?
Dim myStrings() As String
myStrings(0) = "Hello World!"
myStrings(1) = "Foobar"
myStrings(2) = "Banana"
myStrings(3) = "Zebra"
myStrings(4) = "Opal"
myStrings(5) = "10.7"
myStrings(6) = " "
myStrings.Sort()
Dim strOut As String
For Each strOut In myStrings
Console.Write(strOut)
Next
UPDATE
You asked this question via e-mail:
thank u sir.. i got u'r answer..
sir suppose i have large data maintain in database.. how can i sort it..
With SQL:
SELECT *
FROM table
ORDER BY column ASC (DESC)
where "table" is the name of your table and "column" is the name of the column you want to sort; ASC is ascending order (lowest value to highest value); DESC is descending order (highest value to
For example, if you have a table like this:
Table name: People
ID Name Age
1 Bob 16
2 Tom 20
3 Jim 14
SELECT *
FROM People
ORDER BY Name ASC
would ouput:
ID Name Age
1 Bob 16
3 Jim 14
2 Tom 20
SELECT *
FROM People
ORDER BY Age DESC
would output:
ID Name Age
3 Tom 20
1 Bob 16
2 Jim 14
Please do not ask me additional questions via e-mail. This is a forum. Post your questions here and I will answer them here.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment