本文整理汇总了C#中Solution.OrderBy方法的典型用法代码示例。如果您正苦于以下问题:C# Solution.OrderBy方法的具体用法?C# Solution.OrderBy怎么用?C# Solution.OrderBy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Solution
的用法示例。
在下文中一共展示了Solution.OrderBy方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestMethod
public void TestMethod(string s, string expectedResultString)
{
expectedResultString = JsonConvert.SerializeObject(JsonConvert.DeserializeObject<string[]>(expectedResultString).OrderBy(ip => ip));
var answer = new Solution().RestoreIpAddresses(s);
var answerString = JsonConvert.SerializeObject(answer.OrderBy(ip => ip));
Assert.AreEqual(expectedResultString, answerString);
}
示例2: TestMethod1
public void TestMethod1(string numsString, string expectedresultString)
{
var nums = JsonConvert.DeserializeObject<int[]>(numsString);
expectedresultString = JsonConvert.SerializeObject(JsonConvert.DeserializeObject<int[]>(expectedresultString).OrderBy(i => i));
var result = new Solution().MajorityElement(nums);
Assert.AreEqual(expectedresultString, JsonConvert.SerializeObject(result.OrderBy(i => i)));
}
示例3: Test
public void Test(string boardString, string wordsString, string expectedFoundWordsString)
{
var board = JsonConvert.DeserializeObject<char[,]>(boardString);
var words = JsonConvert.DeserializeObject<string[]>(wordsString);
var expectedFoundWords = JsonConvert.DeserializeObject<string[]>(expectedFoundWordsString);
var answer = new Solution().FindWords(board, words);
Assert.AreEqual(JsonConvert.SerializeObject(expectedFoundWords.OrderBy(w => w)), JsonConvert.SerializeObject(answer.OrderBy(w => w)));
}
示例4: TestMethod
public void TestMethod(int maxLength, int min, int max, int repeatTimes)
{
Repeat(repeatTimes, () =>
{
var nums = GenerateIntegerArray(0, maxLength, min, max);
var target = Random.Next(min * nums.Length, (max + 1) * nums.Length);
var expectedResult = FourSum(nums, target);
var expectedResultString = JsonConvert.SerializeObject(expectedResult.OrderBy(x => string.Join(",", x)));
var result = new Solution().FourSum(nums, target);
var resultString = JsonConvert.SerializeObject(result.OrderBy(x => string.Join(",", x)));
Assert.AreEqual(expectedResultString, resultString, string.Format("nums: {0}. target: {1}.", JsonConvert.SerializeObject(nums), target));
});
}
示例5: TestMethod
public void TestMethod(string s, string expectedResultString)
{
expectedResultString = JsonConvert.SerializeObject(JsonConvert.DeserializeObject<IList<string>>(expectedResultString).OrderBy(dna => dna));
var answer = new Solution().FindRepeatedDnaSequences(s);
Assert.AreEqual(expectedResultString, JsonConvert.SerializeObject(answer.OrderBy(dna => dna)));
}
示例6: TestMethod1
public void TestMethod1(string num, int target, string expectedResultString)
{
expectedResultString = JsonConvert.SerializeObject(JsonConvert.DeserializeObject<IList<string>>(expectedResultString).OrderBy(x => x));
var results = new Solution().AddOperators(num, target);
Assert.AreEqual(expectedResultString, JsonConvert.SerializeObject(results.OrderBy(x => x)));
}