本文整理汇总了C#中System.Collections.Generic.System.Collections.Generic.List.Sort方法的典型用法代码示例。如果您正苦于以下问题:C# System.Collections.Generic.List.Sort方法的具体用法?C# System.Collections.Generic.List.Sort怎么用?C# System.Collections.Generic.List.Sort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.Generic.System.Collections.Generic.List
的用法示例。
在下文中一共展示了System.Collections.Generic.List.Sort方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetLatestSaveFile
static string GetLatestSaveFile(string gameDir)
{
var files = Directory.EnumerateFiles(gameDir);
var list = new System.Collections.Generic.List<string>(files);
list.Sort();
var last = list[list.Count - 1];
return Path.GetFileName(last);
}
示例2: GetSignature
public static string GetSignature(string appkey, string appsecret,
string userID)
{
System.Collections.Generic.List<string> arr = new System.Collections.Generic.List<string>();
arr.Add(appkey.ToLower());
arr.Add(appsecret.ToLower());
arr.Sort();
string appinfo = string.Join(string.Empty, arr.ToArray());
appinfo = GetMd5(appinfo).ToLower();
arr.Clear();
arr.Add(appinfo);
arr.Add(userID.ToLower());
arr.Sort();
string signature = string.Join(string.Empty, arr.ToArray());
signature = GetSha1(signature).ToLower();
return signature;
}
示例3: Random
public void Random()
{
BinaryTree<int> Tree = new BinaryTree<int>();
System.Collections.Generic.List<int> Values = new System.Collections.Generic.List<int>();
System.Random Rand = new System.Random();
for (int x = 0; x < 10; ++x)
{
int Value = Rand.Next();
Values.Add(Value);
Tree.Add(Value);
}
for (int x = 0; x < 10; ++x)
{
Assert.Contains(Values[x], Tree);
}
Values.Sort();
Assert.Equal(Values.ToString(x => x.ToString(), " "), Tree.ToString());
}
示例4: CompareWithCurrent
public bool CompareWithCurrent(int[] mas)
{
if (mas.Length == 0) return false;
var currCopy = CurrentPositions.GetRange(0, CurrentPositions.Count);
var finishMatchesCopy = new System.Collections.Generic.List<int>();
foreach (var item in mas)
{
finishMatchesCopy.Add(item);
};
currCopy.Sort();
finishMatchesCopy.Sort();
if (currCopy.Count != finishMatchesCopy.Count) return false;
for (int i = 0; i < currCopy.Count; i++)
{
if (currCopy[i] != finishMatchesCopy[i])
return false;
}
return true;
}
示例5: Random
public void Random()
{
BinaryTree<int> Tree = new BinaryTree<int>();
System.Collections.Generic.List<int> Values = new System.Collections.Generic.List<int>();
System.Random Rand = new System.Random();
for (int x = 0; x < 10; ++x)
{
int Value = Rand.Next();
Values.Add(Value);
Tree.Add(Value);
}
for (int x = 0; x < 10; ++x)
{
Assert.Contains(Values[x], Tree);
}
Values.Sort();
StringBuilder Builder = new StringBuilder();
Values.ForEach((x) => Builder.Append(x.ToString() + " "));
Assert.Equal(Builder.ToString(), Tree.ToString());
}
示例6: AngleSort
// sortowanie katowe punktow z tablicy p w kierunku przeciwnym do ruchu wskazowek zegara wzgledem punktu centralnego c
// czyli sortowanie wzgledem roznacych katow odcinka (c,p[i]) z osia x
// przy pomocy parametru ifAngleEqual można doprwcyzować kryterium sortowania gdy katy sa rowne
// (domyslnie nic nie doprecyzowujemy, pozostawiamy rowne)
public static Point[] AngleSort(Point c, Point[] p, System.Comparison<Point> ifAngleEqual = null)
{
if (ifAngleEqual == null) ifAngleEqual = (p1, p2) => 0;
if (p == null) throw new System.ArgumentNullException();
if (p.Length < 2) return p;
System.Comparison<Point> cmp = delegate(Point p1, Point p2)
{
int r = -(new Geometry.Segment(c, p1)).Direction(p2);
return r != 0 ? r : ifAngleEqual(p1, p2);
};
var s1 = new System.Collections.Generic.List<Point>();
var s2 = new System.Collections.Generic.List<Point>();
for (int i = 0; i < p.Length; ++i)
if (p[i].y > c.y || (p[i].y == c.y && p[i].x >= c.x))
s1.Add(p[i]);
else
s2.Add(p[i]);
s1.Sort(cmp);
s2.Sort(cmp);
s1.AddRange(s2);
return s1.ToArray();
}
示例7: GetAllChatInfoBySort
public System.Collections.Generic.List<MessageCenterChatInfo> GetAllChatInfoBySort()
{
System.Collections.Generic.List<MessageCenterChatInfo> result;
try
{
System.Collections.Generic.List<MessageCenterChatInfo> messageChatInfoList = null;
ChatInfoList chatInfolist = this.GetLocalChatInfoList();
if (chatInfolist != null && chatInfolist.chatinfo != null)
{
messageChatInfoList = new System.Collections.Generic.List<MessageCenterChatInfo>();
foreach (ChatInfo chatInfo in chatInfolist.chatinfo)
{
if (chatInfo != null)
{
messageChatInfoList.Add(new MessageCenterChatInfo
{
Id = chatInfo.id,
Name = chatInfo.name,
LastTime = chatInfo.lasttime,
Type = (MessageCenterType)System.Enum.Parse(typeof(MessageCenterType), chatInfo.type.ToString())
});
}
}
messageChatInfoList.Sort(new System.Comparison<MessageCenterChatInfo>(this.CompareChatInfoValue));
result = messageChatInfoList;
return result;
}
}
catch (System.Exception e)
{
ServiceUtil.Instance.Logger.Error(e.ToString());
}
result = null;
return result;
}
示例8: EditPublishPreferencesGrid
private void EditPublishPreferencesGrid()
{
Ektron.Cms.Framework.Notifications.NotificationPublishPreference _publishPrefApi = new Ektron.Cms.Framework.Notifications.NotificationPublishPreference();
System.Collections.Generic.List<NotificationPublishPreferenceData> publishPrefList = new System.Collections.Generic.List<NotificationPublishPreferenceData>();
publishPrefList = _publishPrefApi.GetList(uId);
publishPrefList.Sort(new NotificationPublishPreferenceData());
PrivacyGrid.Columns.Add(_refStyle.CreateBoundField("TYPE", m_refMsg.GetMessage("generic actions"), "title-header", HorizontalAlign.Left, HorizontalAlign.NotSet, Unit.Percentage(20), Unit.Percentage(20), false, false));
PrivacyGrid.Columns.Add(_refStyle.CreateBoundField("ENABLED", "<center>" + m_refMsg.GetMessage("generic publish") + "</center>", "title-header", HorizontalAlign.Left, HorizontalAlign.NotSet, Unit.Percentage(5), Unit.Percentage(5), false, false));
System.Data.DataTable dt = new System.Data.DataTable();
System.Data.DataRow dr;
dt.Columns.Add(new System.Data.DataColumn("TYPE", typeof(string)));
dt.Columns.Add(new System.Data.DataColumn("ENABLED", typeof(string)));
foreach (NotificationPublishPreferenceData prefEntry in publishPrefList)
{
dr = dt.NewRow();
dr["TYPE"] = GetResourceText(prefEntry.ActivityTypeName);
if (prefEntry.IsEnabled)
{
dr["ENABLED"] = "<center><input type=\"Checkbox\" name=\"pref" + prefEntry.ActivityTypeId + "\" id=\"pref" + prefEntry.ActivityTypeId + "\" checked=\"checked\" /></center>";
}
else
{
dr["ENABLED"] = "<center><input type=\"Checkbox\" name=\"pref" + prefEntry.ActivityTypeId + "\" id=\"pref" + prefEntry.ActivityTypeId + "\" /></center>";
}
dt.Rows.Add(dr);
}
System.Data.DataView dv = new System.Data.DataView(dt);
PrivacyGrid.DataSource = dv;
PrivacyGrid.DataBind();
}
示例9: ShouldInitiateOutboundCallWithCallbackEvents
public void ShouldInitiateOutboundCallWithCallbackEvents()
{
IRestRequest savedRequest = null;
mockClient.Setup(trc => trc.Execute<Call>(It.IsAny<IRestRequest>()))
.Callback<IRestRequest>((request) => savedRequest = request)
.Returns(new Call());
var client = mockClient.Object;
var options = new CallOptions();
options.To = TO;
options.From = FROM;
options.Url = URL;
options.StatusCallback = "http://example.com";
string[] events = { "initiated", "ringing", "completed" };
options.StatusCallbackEvents = events;
client.InitiateOutboundCall(options);
mockClient.Verify(trc => trc.Execute<Call>(It.IsAny<IRestRequest>()), Times.Once);
Assert.IsNotNull(savedRequest);
Assert.AreEqual("Accounts/{AccountSid}/Calls.json", savedRequest.Resource);
Assert.AreEqual(Method.POST, savedRequest.Method);
Assert.AreEqual(7, savedRequest.Parameters.Count);
var fromParam = savedRequest.Parameters.Find(x => x.Name == "From");
Assert.IsNotNull(fromParam);
Assert.AreEqual(FROM, fromParam.Value);
var toParam = savedRequest.Parameters.Find(x => x.Name == "To");
Assert.IsNotNull(toParam);
Assert.AreEqual(TO, toParam.Value);
var urlParam = savedRequest.Parameters.Find(x => x.Name == "Url");
Assert.IsNotNull(urlParam);
Assert.AreEqual(URL, urlParam.Value);
var callbackParam = savedRequest.Parameters.Find(x => x.Name == "StatusCallback");
Assert.IsNotNull(callbackParam);
Assert.AreEqual("http://example.com", callbackParam.Value);
var eventParams = savedRequest.Parameters.FindAll(x => x.Name == "StatusCallbackEvent");
Assert.IsNotNull(eventParams);
Assert.AreEqual(3, eventParams.Count);
var values = new System.Collections.Generic.List<string>();
eventParams.ForEach((p => values.Add(p.Value.ToString())));
values.Sort();
Assert.AreEqual(new List<string>() { "completed", "initiated", "ringing" }, values);
}
示例10: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
int nextColor = 0 ;
int nrOfEvents = 0 ;
EventColor bc ;
System.Collections.Generic.List<Ektron.Cms.Common.Calendar.WebEventData> eventList =
new System.Collections.Generic.List<Ektron.Cms.Common.Calendar.WebEventData>();
System.Collections.Generic.List<MyWebEventData> MyEventList =
new System.Collections.Generic.List<MyWebEventData>();
Ektron.Cms.Framework.Calendar.WebEvent weAPI =
new Ektron.Cms.Framework.Calendar.WebEvent();
System.DateTime st = DateTime.Now.AddDays( 0 - _daysBehind);
System.DateTime et = DateTime.Now.AddDays(_daysAhead);
System.DateTime firstEvent = et ;
System.DateTime lastEvent = st ;
foreach (CalendarDataSource cds in _calendarsource)
{
if( cds.backColor == EventColor.AutoSelect )
{
bc = (EventColor) ((nextColor % 7 /* 11 */) +1) ;
nextColor ++ ;
}
else
bc = cds.backColor ;
eventList = weAPI.GetEventOccurrenceList( cds.defaultId, st, et) ;
foreach( Ektron.Cms.Common.Calendar.WebEventData wed in eventList )
{
MyEventList.Insert( 0, new MyWebEventData( wed, bc ) );
}
}
MyEventList.Sort(delegate(MyWebEventData we1, MyWebEventData we2){ return we1.EventStartUtc.CompareTo(we2.EventStartUtc);});
StringBuilder sb = new StringBuilder();
StringBuilder ss = new StringBuilder();
string eventTime = "";
string tooltip = "" ;
string header = "" ;
string eventTitle = "" ;
if( !_suppressWrapperTags )
ss.Append( "\n<SCRIPT type=\"text/javascript\">\n" ) ;
foreach (MyWebEventData webEventData in MyEventList)
{
if( (DateTime.Compare(webEventData.EventStartUtc, System.DateTime.Now)) > 0 )
{
if( lastEvent < webEventData.EventStart )
lastEvent = webEventData.EventStart ;
if( firstEvent > webEventData.EventStart )
firstEvent = webEventData.EventStart ;
eventTime = ((DateTime.Compare(webEventData.EventStart.AddDays(1), webEventData.EventEnd)) == 0) ? "All Day Event" : webEventData.EventStart.ToShortTimeString() + " to " + webEventData.EventEnd.ToShortTimeString();
string strDescription = (webEventData.Description.Length <= 30) ? webEventData.Description : webEventData.Description.Substring(0, 30) + "... ";
eventTitle = String.Format( _eventFormat,
webEventData.Title,
webEventData.Description,
webEventData.Location,
webEventData.EventStart,
webEventData.EventEnd,
eventTime,
webEventData.Quicklink.ToString(),
backColorCategories[ ((int) webEventData.backColor) -1 ]
) ;
if( _suppressWrapperTags )
{
sb.Append( eventTitle ) ;
}
else
{
sb.Append(
" <tr class=\"rsAllDayRow\">\n" +
" <td class=\"rsLastCell\">\n" +
" <div class=\"rsWrap\" style=\"z-index:20;\">\n" +
" <div class=\"rsApt rsCategory" +backColorCategories[ ((int) webEventData.backColor) -1 ] + "\" style=\"width:100%;position:relative; z-index:25;\">\n" +
" <div class=\"rsAptOut\">\n" +
" <div class=\"rsAptMid\">\n" +
" <div class=\"rsAptIn\">\n" +
" <div ID=\"" +this.ClientID +"_Event_" +nrOfEvents.ToString() +"_AptContent\" class=\"rsAptContent\" >\n" +
" <span id=\"" + this.ClientID +"_Event_" +nrOfEvents.ToString() +"_title\" class=\'UpcomingEventsDesc\'>" +eventTitle +"</span>\n" +
" <div id=\"" + this.ClientID +"_Event_" +nrOfEvents.ToString() +"_description\" style=\"display:none;\">\n" +
" <input id=\"" + this.ClientID +"_Event_" +nrOfEvents.ToString() +"_description_ClientState\" name=\"" + this.ClientID +"_Event_" +nrOfEvents.ToString() +"_description_ClientState\" type=\"hidden\" />\n" +
" </div>\n" +
" </div>\n" +
" </div>\n" +
" </div>\n" +
" </div>\n" +
" </div>\n" +
" </div>\n" +
" </td>\n" +
//.........这里部分代码省略.........
示例11: RemoveOldBackupFiles
private static void RemoveOldBackupFiles(string sectionName)
{
string[] files = System.IO.Directory.GetFiles(RemoteConfigurationManager.instance.config.LocalApplicationFolder, sectionName + ".*.config");
if (files.Length > RemoteConfigurationManager.instance.config.MaxBackupFiles)
{
System.Collections.Generic.List<string> lst = new System.Collections.Generic.List<string>(files);
lst.Sort();
while (lst.Count > RemoteConfigurationManager.instance.config.MaxBackupFiles)
{
System.IO.File.Delete(lst[0]);
lst.RemoveAt(0);
}
}
}
示例12: resetOrder
private void resetOrder()
{
applyNewChallengeFiltering(new ContainsFilter(""), CompletedBehaviour.DO_NOTHING);
challengeViews.OrderBy(x => x.Id);
var tempList = new System.Collections.Generic.List<ChallengeView>();
foreach (var item in challengeViews)
{
tempList.Add(item);
}
tempList.Sort((x, y) =>
{
if (x.Id < y.Id)
{
return -1;
}
return 1;
});
challengeViews.Clear();
foreach (var item in tempList)
{
challengeViews.Add(item);
}
}
示例13: CustomLispWrite
public void CustomLispWrite(Writer Writer)
{
System.Collections.Generic.List<Type> types = new System.Collections.Generic.List<Type>(this.GetType().Assembly.GetTypes());
types.Sort(CompareTypeNames);
foreach(Type type in types) {
SupertuxObjectAttribute objectAttribute = (SupertuxObjectAttribute)
Attribute.GetCustomAttribute(type, typeof(SupertuxObjectAttribute));
if(objectAttribute == null)
continue;
string name = objectAttribute.Name;
LispSerializer serializer = new LispSerializer(type);
foreach(object Object in GetObjects(type)) {
serializer.Write(Writer, name, Object);
}
}
}
示例14: AddShowItemToTree
////// //////// ////// //////// ////// //////// ////// //////// ////// //////// ////// //////// ////// ////////
public TreeNode AddShowItemToTree(ShowItem si)
{
TheTVDB db = this.mDoc.GetTVDB(true, "AddShowItemToTree");
string name = si.ShowName;
SeriesInfo ser = db.GetSeries(si.TVDBCode);
if (string.IsNullOrEmpty(name))
{
if (ser != null)
name = ser.Name;
else
name = "-- Unknown : " + si.TVDBCode + " --";
}
TreeNode n = new TreeNode(name);
n.Tag = si;
if (ser != null)
{
if (mDoc.Settings.ShowStatusColors != null)
{
if (mDoc.Settings.ShowStatusColors.IsShowStatusDefined(si.ShowStatus))
{
n.ForeColor = mDoc.Settings.ShowStatusColors.GetEntry(false, true, si.ShowStatus);
}
else
{
Color nodeColor = mDoc.Settings.ShowStatusColors.GetEntry(true, true, si.SeasonsAirStatus.ToString());
if (!nodeColor.IsEmpty)
n.ForeColor = nodeColor;
}
}
System.Collections.Generic.List<int> theKeys = new System.Collections.Generic.List<int>(ser.Seasons.Keys);
// now, go through and number them all sequentially
//foreach (int snum in ser.Seasons.Keys)
// theKeys.Add(snum);
theKeys.Sort();
foreach (int snum in theKeys)
{
string nodeTitle = snum == 0 ? "Specials" : "Season " + snum;
TreeNode n2 = new TreeNode(nodeTitle);
if (si.IgnoreSeasons.Contains(snum))
n2.ForeColor = Color.Gray;
else
{
if (mDoc.Settings.ShowStatusColors != null)
{
Color nodeColor = mDoc.Settings.ShowStatusColors.GetEntry(true, false, ser.Seasons[snum].Status.ToString());
if (!nodeColor.IsEmpty)
n2.ForeColor = nodeColor;
}
}
n2.Tag = ser.Seasons[snum];
n.Nodes.Add(n2);
}
}
this.MyShowTree.Nodes.Add(n);
db.Unlock("AddShowItemToTree");
return n;
}
示例15: BindTags
private void BindTags()
{
System.Collections.Generic.List<string> col = new System.Collections.Generic.List<string>();
foreach (Training cls in Training.Trainings)
{
foreach (string tag in cls.Tags)
{
if (!col.Contains(tag))
col.Add(tag);
}
}
foreach (Curricula cls in Curricula.Curriculas)
{
foreach (string tag in cls.Tags)
{
if (!col.Contains(tag))
col.Add(tag);
}
}
col.Sort(delegate(string s1, string s2) { return String.Compare(s1, s2); });
foreach (string tag in col)
{
HtmlAnchor a = new HtmlAnchor();
a.HRef = "javascript:void(0)";
a.Attributes.Add("onclick", "AddTag(this)");
a.InnerText = tag;
phTags.Controls.Add(a);
}
}