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

  • Home
  • SEARCH
  • 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 997413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T07:01:51+00:00 2026-05-16T07:01:51+00:00

I have a number of Typed TLists which I am having problems getting to

  • 0

I have a number of Typed TLists which I am having problems getting to sort

Normally, for an untyped TList, I would have a function such as:

function SortByJob(Item1: Pointer; Item2: Pointer): Integer;
var
  p1, p2: JobPointer;
begin
   p1 := JobPointer(Item1);
   p2 := JobPointer(Item2);
   if p1.job > p2.job then
      Result := 1
   else
      if p1.job = p2.job then
         Result := 0
      else
         Result := -1
end;

Which would be called by the list

JobList.Sort(SortByJob)

However I have decided in my current application that we want to lock the TLists to certain pointer types, so in the above example we would have the JobList declared as:

JobList: array[0..4] of TList<JobsPointer>;

Now when I call

JobList[0].Sort(SortByJob)

I get a “not enough parameters” error.

Any ideas?

I have compared that if I use the Sort function above on an untyped “standard” TList then it will compile correctly…

  • 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-16T07:01:52+00:00Added an answer on May 16, 2026 at 7:01 am

    A generic list is sorted using a instance of IComparer. Here is an example that sorts a list of integers:

    uses Generics.Collections, Generics.Defaults;
    
    procedure TForm1.FormCreate(Sender: TObject);
    var
      L : TList<integer>;
    begin
      L := TList<integer>.Create;
      L.Add(2);
      L.Add(1);
    
      L.Sort(TComparer<integer>.Construct(
        function (const L, R: integer): integer
        begin
          Result := L - R;
        end
      )) ;
    
      L.Free;
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an input field in which a serial number will be typed. The
I have a small UIImage (jpg) with a single typed number. I want to
dear all..i have a textfield. i want after i have typed identity number inside
I have several field that just get number, I want if user typed be
Using scanf, each number typed in, i would like my program to print out
I have the following JSON String { name:Product, properties: { id: { type:number, description:Product
In Oracle, I have a table with a column of data type NUMBER. I
I have 3 edittexts with input type as number and 1 button that say
I have a form with number of submit type as images. Each image has
I have a simple custom NumberField: class NumberInput(forms.widgets.Input): input_type = 'number' class NumberField(forms.DecimalField): def

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.