Sort Words by Length in Python

  • Share this:

Code introduction


Sorts a list of words by their length


Technology Stack : os, re, math, json, sys, time, random

Code Type : Function

Code Difficulty : Intermediate


                
                    
import os
import re
import math
import json
import sys
import time
import random

def sort_words_by_length(words):
    return sorted(words, key=len)