Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8732337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:25:18+00:00 2026-06-13T09:25:18+00:00

I am working with sorting methods and random. Button1 Creates the parameter randomize numbers,

  • 0

I am working with sorting methods and random. Button1 Creates the parameter randomize numbers, size, and the maximum number limit to work from. Then according to what linear method is chosen, Button2 Sorts those numbers and then uses a stopwatch to time how long it took. I am currently implementing away to show : sort method, size, time_tosort and number of operations in a text file. So I have the first part done, when program loads I have prompted the user to create a file for where the results will be stored.

What ways can I go about appending the results into the textFile and averaging the results ? Also would I need to add a button to close the write function after user finishes sorting?

Example of desired format: sort method, size, time_tosort and number of operations

Linear 10000 .9 100,000,000
Linear 10000 .8 110,000,000
Linear 10000 .75 150,000,000
Linear 10000 .50 70,000,000
Linear 10000 .7375  107,500,000 ---- AVG

CODE

namespace sortMachine
{
    public partial class Form1 : Form
    {

        public Form1()
        {
            InitializeComponent();

        }

        private void Save()
        {
            var saveReport = new SaveFileDialog();
            saveReport.Filter = "Text Files | *.txt";
            var result = saveReport.ShowDialog();

            if (result == DialogResult.Cancel || string.IsNullOrWhiteSpace(saveReport.FileName))
                return;

            using (var writer = new StreamWriter(saveReport.FileName))
            {
                writer.Write(textBox1.Text);
                writer.Close();
            }
        }

        private List<string> messages = new List<string>() { "Linear", "Bubble", "Index", "Other" };
        private int clickCount = 0;

        Stopwatch sw = new Stopwatch();

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {

            }
            else if (textBox7.Text == "Bubble")
            {
            }
            else if (textBox7.Text == "Index")
            {
            }
            else if (textBox7.Text == "Other")
            {
            }
            else if (textBox7.Text == "")
            {
                MessageBox.Show("Please input a sorting method");
            }
        }

    private void Form1_Load(object sender, EventArgs e)
    {
        Save();
    }

    private void button3_Click(object sender, EventArgs e)
    {
        textBox7.Text = messages[clickCount];
        clickCount++;
        if (clickCount == messages.Count)
            clickCount = 0;
    }
}

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T09:25:19+00:00Added an answer on June 13, 2026 at 9:25 am

    I didn’t look through all the code, but you have two three parts to your question:

    How can I sort/average the results? Once you have a List of your results, you can call .Average(), .OrderBy(), and so on on them. These are part of the System.Linq namespace. (Full list of useful functions here.)

    How can I output it to a text file? Take a look at the File.IO namespace. Here’s a guide.

    How can I get the data for the result? Your best bet is to create a new class:

    class SortData
    {
       public string SortMethod;
       public int Size;
       public TimeSpan TimeToSort;
       public int NumberOfOperations;
    }
    

    Create a List<SortData> and put all your results in there, each as a new SortData(). Then you can do something along these lines:

    foreach (var data in myList)
    {
       Console.WriteLine(SortMethod + "\t" + Size + "\t" + TimeToSort + "\t" + NumberOfOperations);
    }
    

    You’ll need to output to the file instead of the console, but the idea is the same.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working with random and sorting methods. So far I have the linear
I am sorting & grouping publication data from an XML file. The methods I
can't get sorting working for a django-tables2 table. class MyModel(models.Model): pid = models.AutoField('id',primary_key =
I'm working on sorting a list of objects, and unfortunately, I'm not quite getting
I have recently been working to better my understanding of sorting algorithms and their
I can't figure out why sorting is not working in my SSRS Report. I
Just discovered an issue with the sorting plugin used on our cart, was working
I'm trying to sort a list and to check my sorting algorithm is working
Working with an undisclosed API, I found a function that can set the number
I got the below code from internet. It is working properly. I have added

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.