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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:49:00+00:00 2026-06-01T17:49:00+00:00

float[float] aa = [2.2:7.7, 3.3:6.6, 1.1:4.4]; std.sort(aa); assert(aa == [1.1:4.4, 2.2:7.7, 3.3:6.6]); The above

  • 0
float[float] aa = [2.2:7.7, 3.3:6.6, 1.1:4.4];
std.sort(aa);
assert(aa == [1.1:4.4, 2.2:7.7, 3.3:6.6]);

The above doesn’t work. How does one sort aa in place ?

  • 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-01T17:49:01+00:00Added an answer on June 1, 2026 at 5:49 pm

    D’s built-in associative arrays are hash tables. They’re unsorted, and it makes no sense to sort them. The only time that sorting would make any sense would be when iterating over the AA, and to do that requires putting them in a new container. So, you could do something like

    auto keys = aa.keys;
    sort(keys);
    

    but you can’t sort the AA itself. If you want a sorted map, then you need to use something like std.container.RedBlackTree – though it does take a little bit of work to make it function as a map rather than a set (e.g. the sort function must sort on the key only, and when passing stuff to some functions, you need a tuple with a dummy value).

    This is why Java has a HashMap and a SortedMap and why C++ has unordered_map (C++11) and map. They both are maps both they have very different characteristics – particularly with regards to sorting and lookup times.

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

Sidebar

Related Questions

Why does that work? #include <iostream> using namespace std; int main() { float* tab[3];
I'm trying to convert std::string to float/double . I tried: std::string num = 0.6;
struct Vector { float i,j,k; } std::vector pt[size]; ... = ... + pt[temp]; temp
There is a vector of vectors: std::vector <std::vector <float> > VoV; VoV.resize(num); // num
equivalent to log10(2^24) ≈ 7.225 decimal digits Wikipedia Precision: 7 digits MSDN 6 std::numeric_limits<float>::digits10
#include <iostream> using namespace std; int main() { float result = 50.0f; float multiplier
std::vector<float> someOp(void) { using namespace std; vector<float> results; // some operations done to results
Code: #include<iostream> using namespace std; class MyClassOne; class MyClassTwo { int myInteger; float myFloat;
My code is as follows: #include <cmath> #include <iostream> float foo(float f) { std::cout
float Calculate(const string &query) { std::cout << Query: << query << \n; unsigned int

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.