排序

  案件登记-000001→受理初审-000002→受理审查-000003→受理审核-000004→受理审定-000005→受理意见书-000006→批办拟单-000008→拟办审核-000009→审办-000010→批办-000011→批办意见书-000012→案件报结-000015→下级报审-000016→完结案件-000017  
    /// <summary>
    /// 排序
    /// </summary>
    /// <param name="flow"></param>
    /// <returns></returns>
    private string LetterNodeSort(string flow)
    {
        string[] ArrayFlow = flow.Split('→');
        string[] LetterNodes = ArrayFlow;
        string[] LetterNode2 =new string[ArrayFlow.Length-1];
        string[] NewNodes = new string[ArrayFlow.Length];
        string[] Nodes = new string[2];        
        string TempFlow = string.Empty;        
        int nowNode = 0;
        int tempNode = 0;
        int nextNode = 0;
        int p = 0;

        for (int i = 0; i < ArrayFlow.Length ; i++)
        {
            p = 0;
            for (int j = 0; j < LetterNodes.Length - 1; j++)
            {  
                nextNode = getNodeCode(LetterNodes, j+1);               
                tempNode = getNodeCode(LetterNodes, p);
                if ( nextNode < tempNode)
                {
                    p = j+1;
                }
            }

            LetterNode2 = new string[LetterNodes.Length - 1];
            int m = 0;
            for (int j = 0; j < LetterNodes.Length; j++)
            {
                if (j != p)
                {
                    LetterNode2[m] = LetterNodes[j];
                    m = m + 1;
                }
            }          

            NewNodes[i] = LetterNodes[p];
            LetterNodes = LetterNode2;
        }


        string Msg = string.Empty;
        for (int i = 0; i < NewNodes.Length ; i++)
        {
            Msg += NewNodes[i] + "→";
        }
        return Msg.Substring(0, Msg.Length - 1);
    }

   private int getNodeCode(string[] ArrayFlow,int i)
    {
        string[] Nodes = new string[2];
        Nodes = ArrayFlow[i].Split('-');
        return  getInt(Nodes[1]);
    }

    private int getInt(string Value)
    {
        return Convert.ToInt32(Value);
    }

你可能感兴趣的:(排序)