Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6545077
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:32:33+00:00 2026-05-25T11:32:33+00:00

Supose you have an int Key, that when shown and sorted together with other

  • 0

Supose you have an int Key, that when shown and sorted together with other keys will be, of course, sorted following the natural numbers order.

So, to obtain the “Inverse” you can program…

int InverseSortKey = Int32.MaxValue - ArbitraryIntKey;

Question is: How to get a similar “inverse” value, but for strings?

Example:

string InverseSortKey = "ZZZZZZZZZ" - ArbirtraryStringKey; // Of course this don't compile.

I hope you get the idea.

  • 1 1 Answer
  • 2 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T11:32:33+00:00Added an answer on May 25, 2026 at 11:32 am

    Naive solution (updated – works if you know the maximum length of all the strings)

    String data;
    StringBuilder resultBuilder = new StringBuilder(maxLength);
    for (int i = 0; i < maxLength; i++)
    {
        Char  c = i < data.length ? data[i] : 0;
        resultBuilder.Append(Char.MaxValue - c);
    }
    String result = resultBuilder.ToString();
    

    Does not take into account the fact that string sorting may vary by culture and does not necessarily match the numerical values of Chars. A full solution would take an ordered list of all the Chars valid character sequences (in the particular expected encoding of these strings) by sort order, and then for each char pick the one that’s the reverse.

    Further disclaimer: Don’t use this solution unless you can assume that the strings are single-byte encoded and sorted exactly by numerical order.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I have the following tables CREATE TABLE plugins ( id int primary key,
Suppose I have a table Item (Id int Primary Key, Number INT) having records
Suppose I have the following method signature int f (int[] values) and I call
Suppose I have a function void myFun(int*) In C++ what exactly does the following
Suppose I have a class T that I want to use as a key
I have a scenario where I have a propertybag of key/values that would look
I have the following tables; CREATE TABLE IF NOT EXISTS `tags` ( `tag_id` int(11)
I have a table with four columns, say P_Key(int), Ref_Key(int), Key(String), Value(Integer). I want
Suppose I have a table like that: create table reserved ( id int(4) primary
I have a class that has 3 properties: class Three { int ID {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.