In the previous article, the author asked the sorting question about how to sort elements in sequence at the time of in?
C #
Using system;
Using system. Collections. Generic;
Using system. LINQ;
Using system. text;
Using system. Data. LINQ;
Namespace consoleapplication36
{
Class Program
{
Static void main (string [] ARGs)
{
Dataclasses1datacontext context = new dataclasses1datacontext ();
Context. log = console. out;
VaR result = From S1 in context. Customers where (New String [] {"UK", "Lisboa"}). Contains (s1.city) Select S1;
VaR result2 = customsort (result. tolist (), new string [] {"UK", "Lisboa "});
Foreach (VAR item in result2)
{
Console. writeline (item. City );
}
Console. Readline ();
}
Static list <customers> customsort (list <customers> list, string [] citys)
{
List <customers> result = new list <customers> ();
Foreach (VAR item in citys)
{
VaR query = From S1 in list where s1.city = item select S1;
Foreach (VAR ditem in query)
Result. Add (ditem );
}
Return result;
}
}
}
VB. NET
Module module1
Sub main ()
Dim context as new dataclasses1datacontext ()
Dim lists = From S1 in context. Customers where (new string () {"UK", "Lisboa"}). Contains (s1.city) Select S1
For each item in customsort (lists. tolist (), new string () {"UK", "Lisboa "})
Console. writeline (item. City)
Next
Console. Readline ()
End sub
Function customsort (byval source as List (of MERs mers), byval citys as string ())
Dim result as new list (of MERs mers)
For each item in citys
Dim localitem = item
Dim query = From S1 in source where s1.city = localitem select S1
For each ditem in Query
Result. Add (ditem)
Next
Next
Return result
End Function
End Module
Please note that after the tolist is entered into zookeeper mode, the next msmsort will not send any SQL commands.