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

  • SEARCH
  • Home
  • 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 7792719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T22:16:23+00:00 2026-06-01T22:16:23+00:00

I have created a method of determining whether two strings are sorted. All of

  • 0

I have created a method of determining whether two strings are sorted. All of my test cases work except for one. The code is below.

class Program
{
    static void Main(string[] args)
    {
        bool test1 = isSorted("test1", "test2");
        bool test2 = isSorted("4576", "4567");
        bool test3 = isSorted("test10", "test11");
        bool test4 = isSorted("abdc", "abcd");
    }

    public static bool isSorted(string MyFirstString, string MySecondString)
    {
        string MyFirstCutString = MyFirstString.ToLower();
        string MySecondCutString = MySecondString.ToLower();

        if (MyFirstString.Length > MySecondString.Length)
            MyFirstCutString = MyFirstCutString.Substring(0, MySecondString.Length);
        else if (MySecondString.Length > MyFirstString.Length)
            MySecondCutString = MySecondCutString.Substring(0, MyFirstCutString.Length);

        for (int i = 0; i < MyFirstCutString.Length; i++)
        {
            if (getNumberic(MyFirstCutString[i]) > getNumberic(MySecondCutString[i]))
                return false;
        }

        return true;
    }

    public static int getNumberic(char myLetter)
    {
        switch (myLetter)
        {
            case 'a':
                return 1;
            case 'b':
                return 2;
            case 'c':
                return 3;
            case 'd':
                return 4;
            case 'e':
                return 5;
            case 'f':
                return 6;
            case 'g':
                return 7;
            case 'h':
                return 8;
            case 'i':
                return 9;
            case 'j':
                return 10;
            case 'k':
                return 11;
            case 'l':
                return 12;
            case 'm':
                return 13;
            case 'n':
                return 14;
            case 'o':
                return 15;
            case 'p':
                return 16;
            case 'q':
                return 17;
            case 'r':
                return 18;
            case 's':
                return 19;
            case 't':
                return 20;
            case 'u':
                return 21;
            case 'v':
                return 22;
            case 'w':
                return 23;
            case 'x':
                return 24;
            case 'y':
                return 25;
            case 'z':
                return 26;
            case 'O':
                return 27;
            case '1':
                return 28;
            case '2':
                return 29;
            case '3':
                return 30;
            case '4':
                return 31;
            case '5':
                return 32;
            case '6':
                return 33;
            case '7':
                return 34;
            case '8':
                return 35;
            case '9':
                return 36;
            default:
                return 1000;
        }
    }
}

The results of the tests are as follows:

test1 result is true
test2 result is false
test3 result is false (NOT GOOD!)
test4 result is true

I do not see any flaws in my logic.

  • 1 1 Answer
  • 0 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-06-01T22:16:24+00:00Added an answer on June 1, 2026 at 10:16 pm

    You mixed up O and 0 in the switch. This means 0 gets the numeric value 1000, and sorts behind 1.

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

Sidebar

Related Questions

I have created a new method in one of the project's controllers that it
i have created one method to write to Log file but each time it
I have a table view. I have created a method that takes all the
I have created a method that should ideally take a single Account object and
I have created a custom shipping method to show depo-names from which customers will
I have created a UserControl called AutorControl with a method to clear its textbox:
I have created several UI elements in the viewDidLoad method. I want to change
I have created a gem that adds a new method to the class ActiveRecord::Base.
I have created a class library called AddServiceLibrary in which I have a method
I have created a Webpage which will post as post method..not as get method.

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.