What is Nostr?
aliceif /
npub1vcs…5k9y
2023-07-07 16:03:13
in reply to nevent1q…gcul

aliceif on Nostr: npub1nqp93…mw9sy So funny thing, if you use Linq in C#, OrderBy() followed by ...

npub1nqp93y3l9r4cse4mpqlhuq3mjtctlujgyh8ksx8x57wvzt030epq3mw9sy (npub1nqp…w9sy) So funny thing, if you use Linq in C#, OrderBy() followed by First() actually seems to only do one pass through the list.
So sorting followed by taking the first isn't necessarily even going to do a whole sort

Now i wonder if something like list comprehension in python or libraries like numpy or pandas also do that

Linqpad code sample for C#:

void Main()
{
var random = new Random();
List unsorted = Enumerable.Range(0, 100).Select(x => (x, r: random.Next())).OrderBy(t => t.r).Select(t => new PrinteyNumber { Value = t.x }).ToList();

unsorted.OrderBy(x => x.NoisyValue).First().Dump();
}

// Define other methods and classes here
public class PrinteyNumber
{
private int internalValue;
public int Value { get => internalValue; set => internalValue = value; }
public int NoisyValue
{
get
{
Console.WriteLine(internalValue); return internalValue;
}
}
}
Author Public Key
npub1vcseht7e5w2fw3g0s3yhshjpgh8actwlwsht96468sht3y6agvrsna5k9y