Click here to Skip to main content
15,891,738 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
foreach (var eachProfileUri in AllAssociatedProfileUrisList)
{
    var eachProfileData = CallRestApi("https://" + con.oneViewIP + eachProfileUri, "GET", con.sessionID, con.xApiVersionString);
    var data = eachProfileData["enclosureUri"];
    var enclosuredetails = CallRestApi("https://" + con.oneViewIP + data, "GET", con.sessionID, con.xApiVersionString);
    if (enclosuredetails["enclosureType"].ToString() != "C7000")
    {
        associatedprofileSetList.Add(eachProfileData["name"].ToString());

    }
    else if (enclosuredetails["enclosureType"].ToString() != "SY12000")
    {
             associatedprofileSetList.Add(eachProfileData["name"].ToString());

    }
}
if (associatedprofileSetList.Count() > 0)
{
    //associatedprofileSetList.OrderByDescending(x => x.Product.Name).ToList();
    var assoProfileset = String.Join(",", associatedprofileSetList);
    NetworkDict.Add(property, assoProfileset);
}


[edit]Code block added - OriginalGriff[/edit]

What I have tried:

I have tried creating a list and then trying to sort list by alphabetic wise in descending order. please help me . I am unable to do this.
Posted
Updated 18-Mar-18 23:33pm
v2

Try it this way:

C#
if (associatedprofileSetList.Count() > 0)
{
    //associatedprofileSetList.OrderByDescending(x => x.Product.Name).ToList();
    var assoProfileset = String.Join(",", associatedprofileSetList.OrderByDescending(x => x.Product.Name).ToList());
    NetworkDict.Add(property, assoProfileset);
}
 
Share this answer
 
OrderBy returns a copy of the list in the order you want, it doens't change the list you use OrderBy on. So you need to do;

associatedprofileSetList = associatedprofileSetList.OrderByDescending(x => x.Product.Name).ToList();


Examples[^]
 
Share this answer
 
Try:
C#
List<string> sorted = associatedprofileSetList.OrderbyDescending(a => a).ToList();
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900