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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T00:36:06+00:00 2026-05-19T00:36:06+00:00

I am a newbie in Lisp and I want to learn Lisp programming. I

  • 0

I am a newbie in Lisp and I want to learn Lisp programming.
I want to sort some lists read from a text file, like in the following form:

(a 120 135 124 124)
(b 120 135 124 124)
(c 120 135 124 124)

What is the best way to sort them according to the first integer element or maybe second or third and so on?

I have the following idea:

  1. read them all and put them into a list of lists
  2. iterate over the container list and compare the values of list with following one like in bubble sort.

Are there more suitable data structures to achieve this, maybe like Collections in Java which take comparable objects that contain sort logic and fullfill sorting automatically?

Thank you very much.

  • 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-05-19T00:36:07+00:00Added an answer on May 19, 2026 at 12:36 am

    The standard sort function takes a :key argument that can be used to extract a value from the object to use as the sort key. For your example, if you had each list from the file in a list called objects, the following would destructively sort objects by the first integer element and return a sorted list:

    (sort objects #'< :key #'second)
    

    See http://l1sp.org/cl/sort for the precise specification of Common Lisp’s sort function.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Newbie question. I want to do something like: SELECT c1,c2,c3 FROM TABLE t1 UNION
First, I'm a LISP newbie. What I want to get is a cooperative micro-threading
Another newbie (Common) LISP question: Basically in most programming languages there's a mean for
Assume that I want to draw samples from some probability distribution. In the case
I'm a newbie to LISP. I am attempting to invoke the scheme interpreter from
newbie here. I am trying to learn OOD/OOP and read on the net that
Newbie question: some vendors propose solution like generating dynamic certificates to allow user who
I'm a newbie playing around with Lisp (actually, Emacs Lisp). It's a lot of
Newbie question... The objective: I intend to have an HTML text input field as
newbie for clearcase. Since clearcase's config is rather different from other concept in git,

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.