Menu
×
   ❮   
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI GO KOTLIN SASS VUE DSA GEN AI SCIPY AWS CYBERSECURITY DATA SCIENCE
     ❯   

Excel Tutorial

Excel HOME Excel Introduction Excel Get Started Excel Overview Excel Syntax Excel Ranges Excel Fill Excel Move Cells Excel Add Cells Excel Delete Cells Excel Undo Redo Excel Formulas Excel Relative Reference Excel Absolute Reference Excel Arithmetic Operators Excel Parentheses Excel Functions

Excel Formatting

Excel Formatting Excel Format Painter Excel Format Colors Excel Format Fonts Excel Format Borders Excel Format Numbers Excel Format Grids Excel Format Settings

Excel Data Analysis

Excel Sort Excel Filter Excel Tables Excel Conditional Format Excel Highlight Cell Rules Excel Top Bottom Rules Excel Data Bars Excel Color Scales Excel Icon Sets Excel Manage Rules (CF) Excel Charts

Table Pivot

Table Pivot Intro

Excel Case

Case: Poke Mart Case: Poke Mart, Styling

Excel Functions

AND AVERAGE AVERAGEIF AVERAGEIFS CONCAT COUNT COUNTA COUNTBLANK COUNTIF COUNTIFS IF IFS LEFT LOWER MAX MEDIAN MIN MODE NPV OR RAND RIGHT STDEV.P STDEV.S SUM SUMIF SUMIFS TRIM VLOOKUP XOR

Excel How To

Convert Time to Seconds Difference Between Times NPV (Net Present Value) Remove Duplicates

Excel Examples

Excel Exercises Excel Syllabus Excel Study Plan Excel Certificate

Excel References

Excel Keyboard Shortcuts


Excel Sort


Excel Sorting

Ranges can be sorted using the Sort Ascending and Sort Descending commands.

Sort Ascending: from smallest to largest.

Sort Descending: from largest to smallest.

The sort commands work for text too, using A-Z order.

Note: To sort a range that has more than one column, the whole range has to be selected. Sorting just one can breaks the relationship between columns.

This is shown in an example later in this chapter.

The commands are found in the Ribbon under the Sort & Filter menu ()


Example Sort (text)

Sort the Pokemons in the range A2:A21 by their Name, ascending from smallest to largest (A-Z).

  1. Select A2:A21
  2. Open the Sort & Filter menu
  3. Click Sort Ascending

Note: A1 is not included as it is the header for the column. This is the row that is dedicated to the filter. Including it will blend it with the rest.

Copy Values

The Sort Ascending function successfully sorted the Pokemons by their Name ascending from A-Z.

Try again, this time with Sort Descending to see what that looks like!



Example Sort (numbers)

Sort the Pokemons ascending by their Total stats from smallest to largest.

  1. Select A2:A21

Copy Values
  1. Open the Sort & Filter menu

  1. Click Sort Ascending

Great! The Pokemons were successfully sorted by their Total stats from smallest to largest. The sort commands work for both text and numbers.


A Non-Working Example (sorting one column in a range)

In this example we have two columns with related data. Column A is the Pokemons Names and Column B is their Total stats. Try sorting just one of the columns (A2:A21) ascending by their Names.

The attempt to sort results in a warning.

It is not recommended to sort the names alone because it will break the relationship between the Pokemons Names and their Total stats.

Click "Just sort" to see what happens.

This breaks the relationship with Column A and B. The Pokemons now have wrong Total stats.

Clicking the other option in the warning "Expand and Sort" makes the sort function include Column B and sorts them in relation to each other.


Sorting More Than One Column

Select the whole range when sorting ranges with more than one column.

Note: When sorting multiple columns, it will always sort by the first column (leftmost).

Select A2:B21 and sort the range ascending.

By selecting range A2:B21 it sorts correctly, keeping the relationship between the data (Column A and B).

In the next chapter you will learn about Filter.



×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
sales@w3schools.com

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
help@w3schools.com

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.

Copyright 1999-2024 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.