C # top line

It seems so trivial, but I cannot find an answer from Google.

I got a great value for the line for the semaphore at the end of the sorted list of lines.

It seems to me that char.highest.ToString () should do this - but it compares to low, low.

Obviously, it is impossible to create the maximum possible string, because it will always be lower than the same, + more data, but the lines that I sort are valid path names, and therefore the characters used are limited.

In response to the comments:

In the days before Unicode in Delphi, I would just use # 255. I just want a line that will compare above any possible path. It must be trivial - why is it not?

Answer # 2:

This is not a sort that requires a sentinel, this is the processing after that. I have several lists that I sort (with simplified merging, it won’t do the job.), And I duplicate the code, or I have dummy values ​​that are always compared to high.

+3
source share
3 answers

The string representation of the leading character will contain only one character.

Why don't you just add it as a semaphore after sorting, and not try to make it something that will be sorted later?

Alternatively, you can specify your own comparator, which sorts your token after any other line and otherwise calls the default comparator.

+4
source

LINQ OrderBy(). ...

Char.ConvertFromUtf32(0x10ffff)

... .

+2

Something like that?

public static String Highest(this String value)
{
    Char highest = '\0';
    foreach (Char c in value)
    {
        highest = Math.Max(c, highest); 
    }
    return new String(new Char[] { highest });
}
0
source

Source: https://habr.com/ru/post/1724774/


All Articles