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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T00:29:31+00:00 2026-05-16T00:29:31+00:00

I have a class: public class MyObject { public string Code; public string FullName;

  • 0

I have a class:

public class MyObject
{
public string Code;
public string FullName;
}

I have a List of Myobject objects:

Code FullName
"ABC" "The abc company"
"BBC" "The bbc company"
"CPA" "The cpa company"

My requirement: a matched condition is a Code or FullName contains input word. With matched records, I will sort on Code before and FullName later.

Example:

When user input a string: “bc”, return a list:

Code FullName
"ABC" "The abc company"
"BBC" "The bbc company"

When user input a string: “pa”, return this list (note that "PA" is part of the Code, so it is displayed first):

Code FullName
"CPA" "The cpa company"
"ABC" "The abc company"
"BBC" "The bbc company"

Explain: When sorting, the Code field is more Priority than FullName field. Because, all of records contains the string “pa” but only the record with Code “CPA” contain “pa”, so it must be above.

PS: I’m using .NET 2.0/C# 2.0. String compare in filtering is not case-sensitive.

  • 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-05-16T00:29:31+00:00Added an answer on May 16, 2026 at 12:29 am

    I’d do the following:

    1. create an array of integers that has the same length as your array of companies
    2. iterate over all the companies
    3. test to see if the company code starts with user input, if yes, add 1000 to the int array at the current index.
    4. test to see if the company code contains the user input, if yes, add 100 to the int array at the current index
    5. test to see if the company fullname contains the user input, if yes, add 10 to the int array at the current index.
    6. (add additional tests, in my string search system I ended up having 7 distinct matchings)
    7. sort the company array using the int array as keys
    8. return the first N results from the sorted array, or all results, or all results that have a key larger than 0.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 511k
  • Answers 511k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Try //event[@id="2"]/parent::events/@date Together with the original XPath: //event[@id="2"]/parent::events/@date | //event[@id="2"] May 16, 2026 at 5:25 pm
  • Editorial Team
    Editorial Team added an answer M1 means Milestone 1, it's a release name, like beta… May 16, 2026 at 5:25 pm
  • Editorial Team
    Editorial Team added an answer Enums are just named values so you can use them… May 16, 2026 at 5:25 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Imagine I have an entity: public class MyObject { public string Name { get;
The following code does not compile: public class GenericsTest { public static void main(String[]
I have some code that references an outside DLL which in production will be
Is there a way to collect (e.g. in a List) multiple 'generic' objects that
Suppose I have a simple EventArgs subclass: class MyArgs : EventArgs { } Consider
I've got following java class. package com.org.data.dbresource; import org.springframework.orm.ibatis.SqlMapClientTemplate; public class DBConnectionManager { private
I have a class similar to the one below. How do I call my
I was reading Threading from within a class with static and non-static methods and
I got myself in a situation where using the System.Attribute class seemed (at first
I am using Stripes for a project and have a situation I cannot understand.

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.