Hi I require assistance on how to sort numerous records in C# in chronological order e.g the date of birth, if someone could help me it would be much appreciated.

Thanks

Ryan

How about showing what you have tried AND/OR an example of your records and in what format they are in.

Check out the IComparable and IComparable<T> interfaces which can be used in conjunction with IComparer and IComparer<T> interfaces to implement a sorting class.

Example.

would it b possible if u could give me a example so it could be used as a guideline.

because that example is for vb2003 below is my code bar the sorting if u could help...

using System;
using System.Collections;
using System.Linq;
using System.Text;
using System.IO;

namespace ConsoleApplication1
{

    class Program
    {
        static void Main(string[] args)
        {
            FileStream FileS;
            FileS = new FileStream(@"TXT.txt", FileMode.Open);
            StreamReader file = new StreamReader(FileS);
            Person[] myList = new Person[10];
            int index = 0;
            string str;
            while ((str = file.ReadLine()) != null)
            {


                string[] split = str.Split(',');
                myList[index].surname = split[0];
                myList[index].firstname = split[1];
                myList[index].middlename = split[2];
                DateTime.TryParse(split[3], out myList[index].birthDate);
                //myList[index].gender = split[4];
                index++;
            }
            {
                SortedList sList = new SortedList();
                foreach (Person chaps in myList)
                {
                }
               

                int i = 0;
                bool faz = true;
                while (faz)
                {
                    Console.WriteLine(myList[i].surname);
                    Console.WriteLine(myList[i].firstname);
                    Console.WriteLine(myList[i].middlename);
                    Console.WriteLine(myList[i].birthDate);
                    Console.WriteLine(myList[i].gender);

                    string key = Console.ReadLine();
                    if (key == "N" || key == "n")
                    {
                        i++;

                    }
                    else
                        Console.Clear();
                    {
                        if (key == "P" || key == "p")
                        {
                            i--;

                        }
                        else
                            Console.Clear();
                        {
                            {
                                if (key == "F" || key == "f")
                                {
                                    i = 0;

                                }
                                else
                                    Console.Clear();
                                {
                                    {
                                        if (key == "L" || key == "l")
                                        {
                                            i=9;

                                        }
                                        else
                                            Console.Clear();
                                        {

                                          

                                            }

                                        }

                                        {


                                        }

                                    }


                                }

                            }
                        }
                    }
                }
            }
        }
        public struct Person
        {
            public string surname;
            public string firstname;
            public string middlename;
            public DateTime birthDate;
            public string gender;

            
        }




    }

still not working could give me a example of how this would look please

because that example is for vb2003 below is my code bar the

Err, the example link I gave was for using the interfaces mentioned in Visual C#. But if you google the IComparable interface I am sure you will find plenty of examples.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.