Share via

How to eliminate leading the, a, or an when sorting a column

Nancy Read 0 Reputation points
2026-02-18T14:47:12.8866667+00:00

I want to sort a column of book titles but ignore the, a, or an

Microsoft 365 and Office | Excel | For home | Windows
{count} votes

5 answers

Sort by: Most helpful
  1. Ashish Mathur 101.7K Reputation points Volunteer Moderator
    2026-02-18T23:24:07.2733333+00:00

    Hi,

    In cell B2, enter this formula

    =LET(rng,A2:A8,SORTBY(rng,TRIM(REGEXREPLACE(rng, "(?i)^\s*(?:a|an|the)\b\s*", "",,1)),1))

    Hope this helps.

    User's image

    0 comments No comments

  2. Dana D 0 Reputation points
    2026-02-18T21:42:08.02+00:00

    ... ignore the "a" or "an".

    For the poster, I personally would "greatly" simplify that suggestion, and just sort...

    If I am not mistaken, the t's should be further down on the list

    User's image


  3. riny 20,865 Reputation points Volunteer Moderator
    2026-02-18T15:27:30.9666667+00:00

    Perhaps not the prettiest solution but you could remove the "a " and "an " first as demonstrated in the picture below, and then you can sort the list.

    User's image

    0 comments No comments

  4. IlirU 1,936 Reputation points Volunteer Moderator
    2026-02-18T15:23:34.2333333+00:00

    User's image

    Hi @ Nancy Read,

    Try below formula:

    =BYROW(IFNA(SORT(TEXTSPLIT(TEXTJOIN(";",, A2:A19), " ", ";"), 2), ""), LAMBDA(a, TEXTJOIN(" ",, a)))

    Hope this helps.

    IlirU

    0 comments No comments

  5. Q&A Assist
    2026-02-18T14:47:26.3766667+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    To eliminate leading articles such as "the," "a," or "an" when sorting a column of book titles, you can use a derived column in your SQL query that removes these articles before sorting. For example, you can use the LTRIM and RTRIM functions along with REPLACE to clean up the titles. Here’s an example SQL query that demonstrates this:

    SELECT title
    FROM titles
    ORDER BY LTRIM(REPLACE(REPLACE(REPLACE(title, 'the ', ''), 'a ', ''), 'an ', ''));
    

    This query replaces the leading articles with an empty string before sorting the titles. You can adjust the query according to your specific database and requirements.


    References:

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.