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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:15:24+00:00 2026-06-09T21:15:24+00:00

Simple, I have a struct like this: struct bla{ string name; float depth; }

  • 0

Simple, I have a struct like this:

struct bla{
  string name;
  float depth;
}

I have an bla array, and I want to sort by depth, being the greatest depth first.
What should the delegate do/return? I cant find any concrete example.

  • 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-09T21:15:26+00:00Added an answer on June 9, 2026 at 9:15 pm

    You can use the overload of Array.Sort which takes a Comparison<T>:

    bla[] blas = new[] { 
        new bla() { name = "3", depth = 3 }, 
        new bla() { name = "4", depth = 4 }, 
        new bla() { name = "2", depth = 2 }, 
        new bla() { name = "1", depth = 1 }, 
    };
    
    Array.Sort<bla>(blas, (x,y) => x.depth.CompareTo(y.depth));
    

    On this way you sort the original array instead of creating new one.

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

Sidebar

Related Questions

Suppose I have some simple struct like this: public struct WeightedInt { public int
I have a very simple binary tree structure, something like: struct nmbintree_s { unsigned
The problem is like this: I have an array of 500 pointers which point
I have in mind a construct like this: template <typename T, T defaultValue> struct
I have a struct in my Ruby code that looks somewhat like this Parameter
I have a class with a few simple structs like this (simplified code) inside
I have a code that looks something like this: struct First { int f1;
I have a simple question about .net delegates. Say I have something like this:
I have a model class like this: namespace Models { public struct Localization {
Assuming we have a simple struct like: typedef struct { int d1; int d2;

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.