I have two string array i want to sort both arrays with corresponding value.
string
the values are
5:2000a
6:3000
1:2000b
strind Id contain value 5,6,1
string yearcount contain values 2000a,3000,2000b
i want the output like this
strind Id 5,1,6
string yearcount 2000a,2000b,3000
and imp thing is without using array.sort() function.
please any one help as soon as possible, its very urgent.
VulpesPosted Jan 27, 2012, 5:19 AM
VulpesPosted Jan 27, 2012, 5:54 AM
Pavi SPosted Jan 27, 2012, 5:28 AM
Great, i too find out the answer in the another way. really thanks for your reply.
My code
========
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Buble_Sort_String
{
class Program
{
static void Main(string[] args)
{
string[] s = { "2000a", "2003", "2000b", "2005" };
string[] Id = { "20", "30", "25", "15" };
string temp = string.Empty;
try
{
for (int j = 0; j < s.Length - 1; j++)
{
if (s[j].CompareTo(s[j + 1]) > 0)
{
temp = s[j];
s[j] = s[j + 1];
s[j + 1] = temp;
temp = Id[j];
Id[j] = Id[j + 1];
Id[j + 1] = temp;
}
}
for (int i = 0; i < s.Length; i++)
{
Console.WriteLine(s[i] + " ");
Console.WriteLine(Id[i] + " ");
}
Console.ReadKey();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}
}
Pavi SPosted Jan 26, 2012, 11:06 PM
VulpesPosted Jan 25, 2012, 8:54 AM