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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:38:09+00:00 2026-06-15T23:38:09+00:00

Say, data = { 123: 1, 234: 2, 241: 4 } a = list(sorted(data.items()))

  • 0

Say,

data = { 123: 1, 234: 2, 241: 4 }
a = list(sorted(data.items()))

Isn’t list unnecessary ? I think, sorted(data.items()) itself will return list of tuples ? Why would anyone use list function specifically ?

  • 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-06-15T23:38:09+00:00Added an answer on June 15, 2026 at 11:38 pm

    Yes, sorted returns a list itself. So, calling list() on a list data structure is useless. Calling list() on it is equivalent to sorted(data.items())[:].

    In [7]: print sorted.__doc__
    sorted(iterable, cmp=None, key=None, reverse=False) --> new sorted list
    
    In [8]: lis=[1,2,3]
    
    In [9]: lis
    Out[9]: [1, 2, 3]
    
    In [10]: list(lis)    #same result, but different object. (A shallow copy)
    Out[10]: [1, 2, 3]
    

    list() can be useful if you want to fetch all the values of an iterator :

    In [11]: y=xrange(5)
    
    In [12]: y
    Out[12]: xrange(5)
    
    In [13]: list(y)
    Out[13]: [0, 1, 2, 3, 4]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say I have data like this: <option value=abc >Test - 123</option> <option value=def >Test
The program is supposed to take a file, say data.dat, filled with a list
Say I have the following data IEnumerable<IEnumerable<int>> items = new IEnumerable<int>[] { new int[]
I have a list of numbers, say data = [45,34,33,20,16,13,12,3] I'd like to compute
Say I have a range of data from A1:Y55 containg data like 123 UID
When you say thin data access layer, does this mainly mean you are talking
After obtaining data from a model form based on a Model, say form_data =
I'm creating a class (say, C) that associates data (say, D) with an object
I was wondering... when working with a fixed set of data (say: the population
Lets say I have data in two tables. In one I have Order ID

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.