Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lop.PartitionBy does not guarantee the same order #510

Open
nicewook opened this issue Aug 9, 2024 · 2 comments
Open

lop.PartitionBy does not guarantee the same order #510

nicewook opened this issue Aug 9, 2024 · 2 comments

Comments

@nicewook
Copy link

nicewook commented Aug 9, 2024

I have tested the example of lop.PartitionBy on README.md
It keep changed the order

@dengyunsheng250
Copy link

well i have tested in bash file and it always return the same result

@nicewook
Copy link
Author

sorry for confusion. I mean the parallel version. belows are my test and the result

func ExamplePartitionByParallel3() {
	partitions := lop.PartitionBy([]int{-2, -1, 0, 1, 2, 3, 4, 5}, func(x int) string {
		if x < 0 {
			return "negative"
		} else if x%2 == 0 {
			return "even"
		}
		return "odd"
	})
	fmt.Println(partitions)
	// Output:
	// [[-2 -1], [0 2 4], [1 3 5]]
}

result

=== RUN   ExamplePartitionByParallel3
--- FAIL: ExamplePartitionByParallel3 (0.00s)
got:
[[5 1 3] [2 4 0] [-2 -1]]
want:
[[-2 -1], [0 2 4], [1 3 5]]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants