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 7879025
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:48:43+00:00 2026-06-03T03:48:43+00:00

I have an if statement that compares strings but I want to compare strings

  • 0

I have an if statement that compares strings but I want to compare strings that have the same words but different order and have it returned as true.

string 1 a,b,c

string 2 b,c,a

How can I compare them and have the if statement see it as the same string?

  • 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-03T03:48:43+00:00Added an answer on June 3, 2026 at 3:48 am

    Separate the string using componentsSeperatedByString: using whatever string separates your words (comma, space) and put the result in a NSSet. Do it to both strings and compare the sets for equality.

    Modified method using mutableArray instead of Set for taking problems with duplicate strings into consideration (as described in comments):

    -(BOOL) string: (NSString*) string1 isEqualTo: (NSString*) string2 {
      if (string1.length != string2.length) return NO;
      if ([string1 isEqualToString: string2]) return YES;
    
      NSMutableArray *array1 = [NSMutableArray arrayWithArray: [string1 componentsSeperatedByString: @","]];
      NSMutableArray *array2 = [NSMutableArray arrayWithArray: [string2 componentsSeperatedByString: @","]];
    
      [array1 sortUsingSelector: @selector(compare:)];
      [array2 sortUsingSelector: @selector(compare:)];
    
      return [array1 isEqualToArray: array2];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two strings that i need to compare, but even if they have
I have a class that I want to compare to both strings and symbols
I have a perl code to compare 2 strings First string I get from
I have a function that takes in two strings, and I want to, let's
I have Oracle files that I need to compare to CVS files, but the
I have LINQ statement that looks like this: return ( from c in customers
In an Oracle 10g environment, I have a statement that needs to be executed
I have a SQL statement that looks like: SELECT [Phone] FROM [Table] WHERE (
I have a delete statement that's going against one of my core application tables.
I have an UPDATE statement that's intended to update a status field for a

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.