• bvs23bkv33 (unregistered)

    does it compare users with three names?

  • Little Bobby Tables (unregistered)

    Is there a conscious Hofstadter reference in the evolution of "Frenk" --> "Grenk"?

  • Sally Flynn (unregistered)

    Frenk's code was bad, and Grenk's code is worse… I shudder to think how terrible Henk's code is.

  • Pedro (unregistered)

    This is a Sort function. It seems to do what is requested:

    • sorts by last name
    • duplicate last names are not a problem for sort. This is not a dictionary.
    • single names are sorted into the list as if there's no first name.

    All this sounds good and reasonable. TRWTF is reimplementing the wheel (in a funny looking way), but other than that... it seems to work.

  • (nodebb)

    C# code written by lesser programmers is full of this kind of stuff but using LINQ instead. I particularly dislike ForEach extension method certain people love to use instead of the foreach language construct.

  • Pedro (unregistered) in reply to Mr. TA

    @Mr.TA: AsParallel().Foreach( ...) is sweet sugar though.

  • Pedro (unregistered) in reply to Pedro

    "AsParallel().ForAll( x=> doSomething(x) )", actually.

  • (nodebb) in reply to Pedro

    Perhaps, but the people I'm talking about don't get parallel anyway, they're very intersectional and even perpendicular.

  • CrashMagnet (unregistered) in reply to Mr. TA

    Mr. TA (nodebb) wrote Perhaps, but the people I'm talking about don't get parallel anyway, they're very intersectional and even perpendicular.

    Are they obtuse as well?

  • Brian (unregistered) in reply to Pedro
    This is a Sort function. It seems to do what is requested:
    sorts by last name
    duplicate last names are not a problem for sort. This is not a dictionary.
    single names are sorted into the list as if there's no first name.
    

    Try rereading the article. The requirement was to sort by "lastname,firstname". So ignoring the first name not only doesn't meet the requirement, it also results in an indeterminate sort order in the case of matching last names, which (at least in C++, not so sure about Java) is a big no-no.

  • King (unregistered) in reply to Sally Flynn

    I am just wondering how Aenks code quality is? Super duper marvellous?

  • SG (unregistered)

    What me drives crazy is the waste of cycles. Every compare (multiple times per entry!) will do 4 splits. Every time throwing away the arrays and strings, just to have something for the GC ...

  • (nodebb) in reply to SG

    Yeah I noticed that too right away. Very poor quality code, to put it mildly. The fact that underlying first and last names fields aren't readily available is the TRWTF.

  • KDGregory (unregistered)

    Map<String, ReportPlanDto> mapUsers =

    Somewhere, there's a John Smith that's not getting his TPS reports.

  • snoofle (unregistered) in reply to SG

    But... but... the poor GC needs to feel needed, and the only way for that to happen is for programmers to leave huge quantities of little droppings for it to continuously collect.

    PIty the poor GC.

  • Kleyguerth (github) in reply to Mr. TA

    The articles says the underlying first and last name fields are available, Grenk just decided not to use them, he saw a "comparingByKey" function and used that, without bothering to figure out how to compare by fields in the entry value.

  • (nodebb)

    Some users, like prince, may not have a last name. Or a first name, I suppose, depending on how you want to look at it.

    It’s probably a fair assumption that you’re talking here of https://en.wikipedia.org/wiki/Prince_(musician) ? If so, maybe you should have picked another artist to use as an example, like, say, https://en.wikipedia.org/wiki/Madonna_(entertainer) — wait, hang on …

  • sizer99 (google)

    All these clevar coders getting things done in one line and to hell with the performance. Programmers raised on Java, C#, and RoR think RAM and CPU are infinite. Which they seem to be but then your query that should take 2 seconds takes half an hour.

    I was going to snark about assuming lastname and firstname, which is always wrong, but Remy covered that.

  • (nodebb)

    If a name only has one component then clearly it's the last one as there aren't any components after it. It's also the first one as there aren't any components before it. So if you want to put a one-component name into "firstname.lastname" form then the code does just that.

  • xtal256 (unregistered) in reply to sizer99

    The problem is that although it's just one line, it's a hell of a lot of method calls and complexity. You can cram any amount of code into one line, so I don't understand why people measure it that way.

  • gnasher729 (unregistered) in reply to sizer99

    Look at it in a positive way. When management finds out that this code runs so slow that it costs money, you can make it ten times faster easily and become the hero. Even better, when your amount of data grows tenfold over team, and management finds out again that this code runs so slow that it costs money, you can make it ten times faster again quite easily and be the hero again. And even even better, you can do it another time. The third time, that will be actual work, but you will be the hero once more.

  • Jaloopa (unregistered) in reply to xtal256

    They're paid by the line, but selflessly trying to save their company money

  • (nodebb)

    FWIW, various government TLAs , which of course couldn't possiblly have bad forms for us to fill in, will replace a blank with a default. For example, if you have no middle initial, you will become Dave NMI Jones. So Grenk at the very least should have replaced empty splitX with either "NFN" or "NLN" .

    Guess we better hope there's only one Prince, one Madonna, one Midori, one Slash, ...

  • Torge (unregistered) in reply to SG

    Plus: every split is done with a String parameter, so will require compiling a split pattern :(

  • Hrenk (unregistered) in reply to Sally Flynn

    Yeah my code is bad but you could at least spell my name right.

  • (nodebb)

    Zrenk's code would not make it to TDWTF because it is such complex that you cannot figure out what it is supposed to do in the frist place.

  • (nodebb)

    Zrenk's code would not make it to TDWTF because it is such complex that you cannot figure out what it is supposed to do in the frist place.

  • Barf4Eva (unregistered)

    "You want to display those users in order by "lastname, firstname". Your usernames happen to be in the form "firstname.lastname"."

    Yep, see... there's your WTF.

  • monika watts (unregistered)

    Buy Qvir Kit Online falls under a class of antiviral drugs known as reverse transcriptase inhibitor. It is used in combination with other medications to treat HIV infection. It is also used to treat long-term HBV infection. It treats HIV infection by blocking the growth of the virus and its ability to infect the other liver cells

  • rhicky (unregistered)
    Comment held for moderation.

Leave a comment on “Sort Sort Sort Your Map, Functionally Down the Stream”

Log In or post as a guest

Replying to comment #:

« Return to Article