Can you explain more how your are arriving at this sorting?
Is it by length, or do you have a reference string that you're doing a fuzzy match against?
If the latter, try Googleing "string edit distance c#".

By on 6/9/2010 8:33 AM ()

how would I convert a string to a list of characters?

By on 6/9/2010 9:11 AM ()
1
let l = new ResizeArray<_>("foo")

where ResizeArray is the F# alias for System.Collections.Generic.List. A string is already a seq (IEnumerable) of chars.

By on 6/9/2010 9:44 AM ()

Sure in c# here is my Class that does the sorting:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
    public class ModelPlex: IComparable<ModelPlex>
    {
        private int _ModelNum;
        public int ModelNum
        {
            get { return _ModelNum; }
            set { _ModelNum = value; }
        }
        private string _ModelName;
        public string ModelName
        {
            get { return _ModelName; }
            set { AddModel( value); }
        }
        private int Number;
        string temp;
        bool hasEncounteredNumber;
        bool DigitsDone;
        int spaces;
        private void AddModel(string s)
        {
            //find the numerics first.
            //add each alpha to the alphaportion
            hasEncounteredNumber = false;
            DigitsDone = false;
            _Alpha = "";
            _Omega = "";
            Num = "";
            
            for (int i = 0; i < s.Length; i++)
            {
                if (s.StartsWith("F "))
                    temp = "";
                if (s[i] == ' ')
                {
                    Alpha += "A";
                    continue;
                }
                if (DigitsDone)
                    Omega += s[i];
                if (char.IsLetter(s[i]))
                {
                    if (!hasEncounteredNumber)
                        Alpha += s[i];
                    else if (!DigitsDone)
                    {
                       
                        Omega += s[i];
                        DigitsDone = true;
                    }
                    continue;
                }
                if (char.IsDigit(s[i]))
                {
                    hasEncounteredNumber = true;
                    _Alpha += "zz";
                    if (!DigitsDone)
                        Num += s[i];
                }
            }
            if (_Alpha.Length == 0)
                _Alpha = "ZZZZ";
            _ModelName = s;
            if (_Omega.Length == 0)
                _Omega = "$";
            if (Num.Length > 0)
                theNumber = Convert.ToInt32(Num);
            else
                theNumber = 0;
        }
        private string Num;
   
        private int _TheNumber;
        public int theNumber
        {
            get { return _TheNumber; }
            set { _TheNumber = value; }
        }
        private string _Omega;
        public string Omega
        {
            get { return _Omega; }
            set { _Omega = value; }
        }
        private string _Alpha;
        public string Alpha
        {
            get { return _Alpha; }
            set { _Alpha = value; }
        }
        public int CompareTo(ModelPlex a)
        {
            //if (a.GroupDesc == GroupDesc)
            //    return 0;
            if (String.Compare(this._Alpha, a.Alpha) < 0)
                return -1;
            else if (String.Compare(this._Alpha, a.Alpha) > 0)
                return 1;
            if (this._TheNumber > a.theNumber )
                return 1;
            if (this._TheNumber < a.theNumber)
                return -1;
            if (String.Compare(this._Omega, a.Omega) < 0)
                return -1;
            else if (String.Compare(this._Omega, a.Omega) > 0)
                return 1;
            return 0;
           
        }
    }
By on 6/9/2010 8:40 AM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper