keepcalculator

06 Numbers and Powers

Compare Two Lists Case Sensitive

Card No. 06·55347 · Updated · Standard formula, shown below

The calculator on this card is switched off while it is checked. The formula is below, and the worked example shows how to do the sum by hand.

Comparing two lists case sensitively means checking whether each item in one list appears in the other list, but treating Apple and apple as different values. You enter or paste two lists, and the comparison returns which items are shared, which are only in the first list, and which are only in the second list, using exact case matching. This is useful for data cleaning, checking duplicates, or reconciling account names where case matters.

Formula

The comparison uses exact string matching: each line in List 1 is compared to each line in List 2 using case-sensitive equality. No normalization (lowercasing, trimming) is applied.

Let A = set of items in List 1, B = set of items in List 2. Then:

  • Common = { x ∈ A | x ∈ B }
  • Only in List 1 = { x ∈ A | x ∉ B }
  • Only in List 2 = { x ∈ B | x ∉ A }

Each line is treated as a distinct item. If a list contains duplicates, each occurrence is considered; the output shows the duplicates as separate lines (so you can see frequency, not just unique values).

Worked Example

Using the default values:

  • List 1: apple, Banana, cherry
  • List 2: Banana, cherry, date

Compare each item:

  • apple – in List 1 only → Only in List 1
  • Banana – in both → Common
  • cherry – in both → Common
  • date – in List 2 only → Only in List 2

Result: Common = Banana, cherry; Only in List 1 = apple; Only in List 2 = date.

Why Case Sensitivity Matters

Case-sensitive comparison treats Apple, APPLE, and apple as three different items. This is essential in contexts where case is meaningful:

  • Programming identifiers – variable names like userID vs userid are different.
  • Passwords and tokens – case matters for security.
  • File names on Linux – Readme.txt and readme.txt can coexist.
  • Database queries – depending on collation, case sensitivity affects results.

If you need to ignore case, you would lowercase both lists first. This calculator does not do that – it gives you the raw case-sensitive result.

How to Use the Calculator

  1. Paste or type your first list into the List 1 field, one item per line.
  2. Paste or type your second list into the List 2 field, one item per line.
  3. Click the calculate button (or the output updates automatically).
  4. Read the three output lists: Common, Only in List 1, Only in List 2.

Items are compared exactly as typed – spaces, punctuation, and capitalization all matter. If you have trailing spaces, they are considered part of the item.

Common Mistakes and Pitfalls

  • Ignoring whitespace – apple (with a space) is not the same as apple.
  • Assuming case-insensitivity – many people expect Cat and cat to match, but they don’t here.
  • Overlooking duplicates – if a list has apple twice and the other has it once, the common output will show apple once (since it appears in both), but the duplicate in List 1 will appear in “Only in List 1” as a second occurrence.
  • Mixing line endings – if you copy from Windows, lines may have \r\n; the calculator trims the \r automatically, but be aware.

When to Use Case-Sensitive Comparison

Use case-sensitive comparison when:

  • You are comparing usernames or emails (though emails are usually case-insensitive, some systems treat them as case-sensitive).
  • You are checking code identifiers or configuration keys.
  • You are merging lists from case-sensitive file systems.
  • You intentionally want to distinguish between USA and usa (e.g., country codes).

If you are comparing human names or general text, you probably want case-insensitive comparison – but that is a different tool.

Alternatives and Related Tools

If case sensitivity is not what you need, consider:

  • Case-insensitive comparison – lowercases both lists before comparing.
  • Trim whitespace – remove leading/trailing spaces before comparing.
  • Compare unique values only – remove duplicates first.
  • Fuzzy matching – for approximate matches (e.g., typos).

This calculator gives you the exact, case-sensitive intersection and differences – a fundamental operation for data cleaning.

Frequently Asked Questions

Does this calculator ignore case?

No. It treats uppercase and lowercase letters as different characters. Apple and apple will not match.

What if my lists have duplicate items?

Duplicates are preserved. If List 1 has apple twice and List 2 has apple once, the common output shows apple once, and the extra apple appears in “Only in List 1”.

Can I compare lists with numbers or special characters?

Yes. Each line is treated as a string. So 123 and 123 match, but 123 and 123 (with a space) do not.

How do I make it case-insensitive?

You would need to convert both lists to lowercase (or uppercase) before pasting. This calculator does not have an option for that.

Does the order of items in the output matter?

The output preserves the order of the first list for “Common” and “Only in List 1”. For “Only in List 2”, it preserves the order of the second list.

What if a line is empty?

An empty line is treated as an empty string. If both lists have an empty line, it will appear as a common item. It is usually best to remove blank lines before comparing.

Related

Formula used
in list1 | List 1 (one item per line) | - | apple\nBanana\ncherry | 0
in list2 | List 2 (one item per line) | - | Banana\ncherry\ndate | 0
out common | Common items (case-sensitive) | - | "" | 0
out only1 | Only in List 1 | - | "" | 0
out only2 | Only in List 2 | - | "" | 0

Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →