Welcome, Guest. Please login or register.
Did you miss your activation email?
Pages: [1]   Go Down
  Print  
Author Topic: Sorting a String or int  (Read 1443 times)
0 Members and 1 Guest are viewing this topic.
Arkie
Javaforums.net Admin
Senior Member
*

Reputation: 16
Developer @ Javaforums.net
Offline Offline
Posts: 2593
Referrals: 13

WWW Awards
« on: February 08, 2009, 08:14:00 PM »

Sort arrays with Java
http://www.engineeringser...g_arrayssort-t2917.0.html

C# version
Code
GeSHi (csharp):
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace SortString
  7. {
  8.    class Program
  9.    {
  10.        static void Main(string[] args)
  11.        {      
  12.            String s = "d a c b";      
  13.            string[] sa = s.Split(' ');
  14.            int[] i = { 4, 1, 3, 2 };
  15.  
  16.            Console.WriteLine("Unsorted:");
  17.            for (int j = 0; j < sa.Length; j++)
  18.            {
  19.                Console.WriteLine(sa[j] + " " + i[j]);
  20.            }  
  21.  
  22.            Array.Sort(sa);
  23.            Array.Sort(i);
  24.  
  25.            Console.WriteLine("\nSorted:");
  26.            for (int j = 0; j < sa.Length; j++)
  27.            {
  28.                Console.WriteLine(sa[j] + " " + i[j]);
  29.            }        
  30.            Console.Read();
  31.        }
  32.    }
  33. }
  34.  
  35.  
Created by GeSHI 1.0.7.20
Logged

Java and .NET developer

To students: It doesn't matter how hard you've studied; the material won't be on the exam anyway.

Fan of http://www.retardedweblogger.com
Oh man, too much stuff to do in so little time.

http://img222.imageshack....707/arkietomatoesmall.jpg
Blizzcon 2k9 Grubby and Cassandra Ng engaged ! <3
Triple D, eerste Denken Dan Doen
jurka
Staff
Member
*
*

Reputation: 5
Offline Offline
Posts: 188
Referrals: 0

Awards
« Reply #1 on: February 09, 2009, 11:12:56 AM »

Pretty much of the style is same as Java. So it's not needed such deep learning curve.
Logged
Arkie
Javaforums.net Admin
Senior Member
*

Reputation: 16
Developer @ Javaforums.net
Offline Offline
Posts: 2593
Referrals: 13

WWW Awards
« Reply #2 on: February 09, 2009, 01:49:41 PM »

Pretty much of the style is same as Java. So it's not needed such deep learning curve.

True, if you know Java, c# isn't a too difficult language to learn. Because i'm currently mainly working in .Net (c#) using visual studio 2005 and 2008 express edition i'll point out the difference between the two languages and hope that people that want to learn .Net or have questions about it will post here as well.
Logged

Java and .NET developer

To students: It doesn't matter how hard you've studied; the material won't be on the exam anyway.

Fan of http://www.retardedweblogger.com
Oh man, too much stuff to do in so little time.

http://img222.imageshack....707/arkietomatoesmall.jpg
Blizzcon 2k9 Grubby and Cassandra Ng engaged ! <3
Triple D, eerste Denken Dan Doen
Pages: [1]   Go Up
  Print  
 
Jump to:  

Your Ad Here