Я настроил это больше и придумал следующий код, и я думаю, что моя единственная проблема в том, как я инструктирую его читать из textbox1 и выводить в textbox2 с инструкциями сортировки. Я боролся с этим в течение выходных и, если кто-нибудь может мне помочь, спасибо!
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
System.Collections.Generic.Dictionary<string, int> myDict = new Dictionary<string, int>();
myDict.Add("one", 1);
myDict.Add("four", 4);
myDict.Add("two", 2);
myDict.Add("three", 3);
var sortedDict = (from entry in myDict orderby entry.Value ascending select entry);
string[] items = textBox1.Text.Split(Environment.NewLine.ToCharArray());
Array.Sort(items, new ??? ());
textBox2.Text = String.Join(Environment.NewLine, items);
}
}
}