Help with sort: it does not seem to do anything.
I'm a bit confused, I have a very simple sort example, but it does not do anything at all. I must be doing something wrong, because I cannot image that I'm the first to touch this code. What is going on here? The following code gives as output:
code:
4 Replies
Here is the issue: https://github.com/modularml/mojo/issues/1508
GitHub
[BUG]: Inplace sort seems to do nothing · Issue #1508 · modularml/m...
Bug description A simple sortDType.uint32 (that is: sort[type: DType](inout v: DynamicVector[SIMD[type, 1]])) does not sort the vector. In fact, it doesn't appear to do anything wha...
Congrats @Henk-Jan Lebbink, you just advanced to level 2!
var data_vec = DynamicVector[UInt32](size)
is not doing what you want. Setting the capacity
to 32 allocates an internal pointer but it leaves data_vec.size
as 0. You want to use .resize(size, 0)
or just add your random numbers with .push_back()
.@Michael K Thanx for the help. Aha capacity instead of size.
__init__(inout self: Self, capacity: Int)